So I am attempting to learn multi-threading in CPP using boosts thread pool (thread_group) and had a question come up regarding management of the thread pool.
So the library is simple enough, initialize a thread group and then call create_thread with the pointer to the function you want to execute within the thread. The thread executes til it is finished, and then terminates. So far this is pretty standard, my question comes after it has been terminated and detached by the OS.
Once this occurs do I have to physically clean up its memory space? In other words, when you create_thread it returns a thread*. Should I be storing that pointer somewhere, and intermittently check to see if the thread is still active? If its not active, do I have to perform the delete to clear the memory space off of the heap?
Please advise. If I do need to do this, what is the simplest solution to manage this? An array of pointers that I traverse to check the status and deallocate them if they arent running?
Worth 500 points.