Quantcast

[thread] thread.join() throws in 1.52.0

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[thread] thread.join() throws in 1.52.0

Szymon Gatner
Hi,

after updating from 1.51.0 to 1.52.0 call to a thread::join() throws "invalid_argument" / not joinable. I see that there is a change with regards to thread d-tor in this version but I don't really understand if and why this is related.

Should joinable() be called now before every join()?

--
Szymon Gatner
The Lordz Games Studio
www.thelordzgamesstudio.com

_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [thread] thread.join() throws in 1.52.0

Igor R.
> after updating from 1.51.0 to 1.52.0 call to a thread::join() throws
> "invalid_argument" / not joinable. I see that there is a change with regards
> to thread d-tor in this version but I don't really understand if and why
> this is related.
>
> Should joinable() be called now before every join()?


Yes, you should check that the thread is joinable or ensure that
BOOST_THREAD_TRROW_IF_PRECONDITION_NOT_SATISFIED is not defined.
http://www.boost.org/doc/libs/1_52_0/doc/html/thread/thread_management.html#thread.thread_management.thread.join
_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [thread] thread.join() throws in 1.52.0

Szymon Gatner
OK, clear. Thing is thread is actually being join()ed by thread_group::join_all() which does not do the check. Is that a bug or I am using it wrong now too?


2012/11/8 Igor R <[hidden email]>
> after updating from 1.51.0 to 1.52.0 call to a thread::join() throws
> "invalid_argument" / not joinable. I see that there is a change with regards
> to thread d-tor in this version but I don't really understand if and why
> this is related.
>
> Should joinable() be called now before every join()?


Yes, you should check that the thread is joinable or ensure that
BOOST_THREAD_TRROW_IF_PRECONDITION_NOT_SATISFIED is not defined.
http://www.boost.org/doc/libs/1_52_0/doc/html/thread/thread_management.html#thread.thread_management.thread.join
_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users



--
Szymon Gatner
The Lordz Games Studio
www.thelordzgamesstudio.com

_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [thread] thread.join() throws in 1.52.0

Igor R.
> OK, clear. Thing is thread is actually being join()ed by
> thread_group::join_all() which does not do the check. Is that a bug or I am
> using it wrong now too?

Not sure if it can be defined as a "bug", but thread_group definitely
doesn't keep up with all the new thread features.
_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [thread] thread.join() throws in 1.52.0

Szymon Gatner

Not sure if it can be defined as a "bug", but thread_group definitely
doesn't keep up with all the new thread features.

 
Understood. A question then: why did this thread became unjoinnable? It was never explicitly detached.

_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [thread] thread.join() throws in 1.52.0

Vicente Botet
In reply to this post by Szymon Gatner
Le 08/11/12 19:28, Szymon Gatner a écrit :
Hi,

after updating from 1.51.0 to 1.52.0 call to a thread::join() throws "invalid_argument" / not joinable. I see that there is a change with regards to thread d-tor in this version but I don't really understand if and why this is related.

Should joinable() be called now before every join()?

Hi,

join() requires that the threads is joinable, as there is only one thread owner the owner is able to know if the thread has been joined or not.

See http://www.boost.org/doc/libs/1_51_0/doc/html/thread/thread_management.html#thread.thread_management.thread.join

void join();
Preconditions:

the thread is joinable.


Note that this requirement was already since 1.45, but the implementation didn't throw.

void join();
Preconditions:

this->get_id()!=boost::this_thread::get_id()


This conforms with the C++11 standard.

You can disable this by commenting this line in the Jamfile

      <define>BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED

The idea was to not commit this line and let the user to define this macro.

Sorry for the disturbance.

Best,
Vicente



_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [thread] thread.join() throws in 1.52.0

Vicente Botet
In reply to this post by Szymon Gatner
Le 08/11/12 21:10, Szymon Gatner a écrit :

Not sure if it can be defined as a "bug", but thread_group definitely
doesn't keep up with all the new thread features.

You are right. I have left thread_group a little bit on the road. Please, could you create a ticket? I will fix this very soon.

 
Understood. A question then: why did this thread became unjoinnable? It was never explicitly detached.

Please, could you post a short example that shows the issue?

Thanks,
Vicente

_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [thread] thread.join() throws in 1.52.0

Igor R.
> You are right. I have left thread_group a little bit on the road. Please,
> could you create a ticket? I will fix this very soon.

Done!

Thanks.
_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Loading...