Hey I made a simple thread pool and well "it works" but I was wondering if there were things I should do or add to make it better? I feel like I'm missing something really important. By the way the linkedlist to store the objects was made by me works the same with std::list but I just felt like using my link list :P.
I was wondering if there were things I should do or add to make it better?
This isn't actually a "thread pool", since it does not use pooled threads.
As far as I can see, here each task is executed in a new (not pooled) thread (line 68) and no new tasks are launched until that task completes and its thread shuts down at line 70.
Also, a major red flag is detach for that useless thread from active_object: the thread can be in that loop around line 68 when the main thread executes delete employees;, In fact, even if it were joined in ~active_object, it would still be live after delete employees;, since the Queue member destructor doesn't run until after that line.
As far as I can see, here each task is executed in a new (not pooled) thread (line 68) and no new tasks are launched until that task completes and its thread shuts down at line 70.
Yes, I'm just storing the tasks for the threads to proceed later. Which I guess your right isn't a threadpool. In that case what should this "thing" be.
Oh and also I changed the thread.join @ line 70 to thread.detach since from my understanding detach allows it to handle its own process/execution without it having to wait so that I could allow more threads to come in. Although thinking about that I'm not sure if that is a good thing mainly since it could lead to it not being thread safe.
Also, a major red flag is detach for that useless thread from active_object: the thread can be in that loop around line 68 when the main thread executes delete employees;, In fact, even if it were joined in ~active_object, it would still be live after delete employees;, since the Queue member destructor doesn't run until after that line.
It's somewhat like a turnstile with unbounded job queue.. except turnstiles don't spawn threads
At least not yet lol. Seriously though is it a good thing that it's like a turnstile. Maybe I should probably fix this up and work on an "actual" thread-pool later hmm.