Free Software Library!

This is a discussion on Free Software Library! within the C++ Programming forums, part of the General Programming Boards category; Well, sort of Basically, I am trying to get people interested in my software components so that one day I ...

  1. #1
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,655

    Post Free Software Library!

    Well, sort of Basically, I am trying to get people interested in my software components so that one day I may perhaps make my living developing them! Sounds kinda kooky, huh? Anyway, here is my first offering: A multithreaded C++ class called QuickThread. Basically, it lets you pack as many void(*)(void) functions into it as you wish, and then runs them continuously in sequence. Adding, removing, starting, stopping, suspending are all as easy as calling a single function. So the point is the class was made for ease of use, targeted toward the beginner but fun enough for the expert. Try it out! The software is free, but not open-source. You may use it for whatever you'd like, both commercial and otherwise - there is no license.


    [edit]

    BTW: please try to use the lib before making random comments!

    [/edit]

    [edit2]

    where'd it go

    I reposted the library below...have fun with it!

    [/edit2]
    Last edited by Sebastiani; 10-09-2002 at 11:01 AM.
    Code:
    #include <ip.hpp>

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,655
    Any comments, complaints, suggestions? Looking for something even more powerful, perhaps? Maybe the end-all-be-all multithreading library? I've got it! But I would like a little feedback on this one first, please . For the reluctant, I will illustrate example one from the package...


    Code:
    #include <windows.h> //...for sleep
    #include <stdio.h>
    #include "QuickThread.h"
    
    
    void This(void)
     {
      printf("This ");
     } 
    
    void Thread(void)
     {
      printf("Thread ");
     }
    
    void Is(void)
     {
      printf("Is ");
     }
    
    void Running(void)
     {
      printf("Running ");
     }
    
    
    
    int main(int argc, char *argv[]){
    
    QuickThread thread;
    
    thread.Add(This, Thread, Is, Running, This);
    
    thread.Start();
    
    Sleep(3000); //...let the thread run for three seconds...
    
    thread.Suspend();
    
    Sleep(3000);  //...let it sleep...
    
    thread.Resume();
    
    Sleep(3000);   //...let it run again for three seconds...
    
    thread.Stop();
    
    return 0;
    }

    Also, here are the Win32 thread priority ID's to be used with QuickThread::Priority():


    THREAD_PRIORITY_IDLE
    THREAD_PRIORITY_LOWEST
    THREAD_PRIORITY_BELOW_NORMAL
    THREAD_PRIORITY_NORMAL
    THREAD_PRIORITY_ABOVE_NORMAL
    THREAD_PRIORITY_HIGHEST
    THREAD_PRIORITY_TIME_CRITICAL
    Code:
    #include <ip.hpp>

  3. #3
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    You should make it platform-independent. One interface that works in both Windows and Linux.

    -You are encouraged to use safe multithreading techniques. If you have never used threads
    before, learn about semaphores, mutexes, and other such mechanisms.
    Why don't you include a wrapper for those things too?

    BTW, your example1.exe doesn't suspend the threads at all. It just floods the screen with text too fast to read.
    Last edited by Sang-drax; 10-09-2002 at 09:24 AM.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  4. #4
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Originally posted by Sebastiani

    thread.Add(This, Thread, Is, Running, This);
    I don't like this syntax at all.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  5. #5
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,655
    You should make it platform-independent
    Sure, I'll work on that.

    Why don't you include a wrapper for those things too?
    I'll let the programmer implement these on his own. Thay are applied to the data structures, and can be easily implemented anyhow.

    BTW, your example1.exe doesn't suspend the threads at all. It just floods the screen with text too fast to read.
    You misunderstand. Notice that the screen pauses and then continues. This was where ::Suspend() was called The QuickThread object executes the functions passed to it continuously. With exception to printing and other purposes, you will want the functions to run quickly. To slow them down, you should place a call to Sleep() in each function or similar.


    I don't like this syntax at all.
    Really, so don't use that syntax. I provided it as a clearer way to place functions into the object. Look at both ways:

    thread.Add(f1);
    thread.Add(f2);
    thread.Add(f3);
    thread.Add(f4);
    thread.Add(f5);
    thread.Add(f6);
    thread.Add(f7);
    thread.Add(f8);
    thread.Add(f9);
    thread.Add(f10);

    ...compared with:


    thread.Add(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10);


    In my opinion, the second is more readable. The point, is that both are equal.
    Code:
    #include <ip.hpp>

  6. #6
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,655
    Sorry, the attachment was lost when I edited that first post! Here it is:

    [edit]

    BTW: there have been 10 downloads so far...

    [/edit]
    Attached Files Attached Files
    Last edited by Sebastiani; 10-09-2002 at 10:58 AM.
    Code:
    #include <ip.hpp>

  7. #7
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Originally posted by Sebastiani
    Notice that the screen pauses and then continues.
    No, I didn't notice that. The text was unable to read.






    thread.Add(f1);
    [...]
    thread.Add(f10);


    thread.Add(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10);

    In my opinion, the second is more readable. The point, is that both are equal.
    I like the second way better too, but your first example went like this:

    thread.Add(This, Thread, Is, Running, This);
    With the first element at the end (as a terminator, I guess because the function is declared with a "..." in the argument list).
    Last edited by Sang-drax; 10-09-2002 at 01:50 PM.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  8. #8
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,655
    With the first element at the end (as a terminator, I guess because the function is declared with a "..." in the argument list).
    No, I was just trying to illustrate that you can add the same function more than once, such that the output would be "This Thread Is Running This".

    No, I didn't notice that. The text was unable to read.
    Add this function to the end and you will get your desired printout:

    void Wait(void){
    Sleep(1000);
    }

    thread.Add(This, Thread, Is, Running, This, Wait);



    Anyway, don't be so negative. If you don't like it, don't use it!
    Code:
    #include <ip.hpp>

  9. #9
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    I know what the problem is now.
    Instead of waiting three seconds (Sleep(3000)) it waited about six seconds for some reason (not your fault).


    I have one question, though.
    First, let me point out that I've never worked that much with functions that take a variable amount of arguments.
    But every use of it I've seen has either used an integer specifying the number of arguments or passing a zero pointer at the end.
    Like this:
    Code:
    func(3,arg1,arg2,arg3);
    //or
    func(arg1,arg2,arg3,0);
    How come your implementation works without using any of these techniques?

    Finally, well, what kind of response did you expect? It's a good library, but it has no great advantage over Win32 API. I don't think my "random comments" have been too negative. An advanced programer like you must be able to cope with them.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What's an import library?
    By chiefmonkey in forum C++ Programming
    Replies: 1
    Last Post: 06-19-2009, 05:00 PM
  2. my free c++ library
    By jinhao in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 11-01-2007, 10:00 PM
  3. Doing research paper, confused by fsf's definition of Free Software.
    By indigo0086 in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 10-13-2007, 09:49 AM
  4. Recommend free flowchart software and guides
    By milkydoo in forum C++ Programming
    Replies: 7
    Last Post: 07-14-2003, 08:10 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21