I'm trying to use this common c++ library on a project, and I'm quite satified with it.
Yet, there is something I haven't been able to code cleanly, using the provided API:
My application needs to start a bunch of threads and to wait for them to finish before continuing with its computation.
I've tried deleting the threads hoping that the main thread would block waiting for them, but the threads got inesorably deleted before they could attempt to do anything useful.
Does your API provide a way to achieve this behaviour?
Thanks a lot
bye
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
A delete normally performs a "join", and hence will wait for the thread to terminate before returning. If you are creating a derived class and calling it's virtual destructor, then you may need to add Terminate() to the derived classes destructor. Also, depending on what the thread does and which services it invokes, you may need to play with setCancel before the thread will cancel, or add Yield points in any loops in your code where appropriate to permit cancellation to occur.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm trying to use this common c++ library on a project, and I'm quite satified with it.
Yet, there is something I haven't been able to code cleanly, using the provided API:
My application needs to start a bunch of threads and to wait for them to finish before continuing with its computation.
I've tried deleting the threads hoping that the main thread would block waiting for them, but the threads got inesorably deleted before they could attempt to do anything useful.
Does your API provide a way to achieve this behaviour?
Thanks a lot
bye
A delete normally performs a "join", and hence will wait for the thread to terminate before returning. If you are creating a derived class and calling it's virtual destructor, then you may need to add Terminate() to the derived classes destructor. Also, depending on what the thread does and which services it invokes, you may need to play with setCancel before the thread will cancel, or add Yield points in any loops in your code where appropriate to permit cancellation to occur.