[spirit] Two failures caused by thread lib updated?

Hello, the multi platform failures observed for grammar_mt_tests and owi_mt_tests seem to correlate to the recent thread lib update: cxx: Error: ../boost/thread/pthread/thread.hpp, line 139: call of an object of a class type without appropriate operator() or conversion functions to pointer-to-function type (badcallclsobj) detected during instantiation of "void boost::thread::thread_data<F>::run() [with F=boost::reference_wrapper<single_grammar_object_task>]" f(); ----------------^ Anyone knows what's going on? Markus

Markus Schöpflin:
Hello,
the multi platform failures observed for grammar_mt_tests and owi_mt_tests seem to correlate to the recent thread lib update:
cxx: Error: ../boost/thread/pthread/thread.hpp, line 139: call of an object of a class type without appropriate operator() or conversion functions to pointer-to-function type (badcallclsobj) detected during instantiation of "void boost::thread::thread_data<F>::run() [with
F=boost::reference_wrapper<single_grammar_object_task>]" f(); ----------------^
Anyone knows what's going on?
I think I do. The new Boost.Threads implements the proposed standard interface where F is expected to be a function object; std::reference_wrapper is, but boost::reference_wrapper isn't. The old Boost.Threads did not suffer from this problem since it stored F in a boost::function, which automatically recognizes reference_wrapper and "dereferences" it before the call. This can be fixed on the user side by wrapping the reference_wrapper in a boost::bind, or it can be fixed on the Boost.Threads side. The third option, making boost::reference_wrapper callable, is a very risky change that I would advise against.

Peter Dimov wrote:
Markus Schöpflin: [...]
F=boost::reference_wrapper<single_grammar_object_task>]" f(); ----------------^
Anyone knows what's going on?
I think I do. The new Boost.Threads implements the proposed standard interface where F is expected to be a function object; std::reference_wrapper is, but boost::reference_wrapper isn't. The old Boost.Threads did not suffer from this problem since it stored F in a boost::function, which automatically recognizes reference_wrapper and "dereferences" it before the call.
This can be fixed on the user side by wrapping the reference_wrapper in a boost::bind, or it can be fixed on the Boost.Threads side. The third option, making boost::reference_wrapper callable, is a very risky change that I would advise against.
(4) create a custom callable object. I'll look into that tomorrow. (I'd rather not introduce an additional dependency for such a simple task.) Thanks for the explanations, m

Peter Dimov wrote:
the multi platform failures observed for grammar_mt_tests and owi_mt_tests seem to correlate to the recent thread lib update:
cxx: Error: ../boost/thread/pthread/thread.hpp, line 139: call of an object of a class type without appropriate operator() or conversion functions to pointer-to-function type (badcallclsobj) detected during instantiation of "void boost::thread::thread_data<F>::run() [with
F=boost::reference_wrapper<single_grammar_object_task>]" f(); ----------------^
Anyone knows what's going on?
I think I do. The new Boost.Threads implements the proposed standard interface where F is expected to be a function object; std::reference_wrapper is, but boost::reference_wrapper isn't. The old Boost.Threads did not suffer from this problem since it stored F in a boost::function, which automatically recognizes reference_wrapper and "dereferences" it before the call.
This can be fixed on the user side by wrapping the reference_wrapper in a boost::bind, or it can be fixed on the Boost.Threads side. The third option, making boost::reference_wrapper callable, is a very risky change that I would advise against.
I strongly object against silently changing the Boost.Thread interface/semantics. So I'ld vote for 2) Regards Hartmut

"Hartmut Kaiser" <hartmut.kaiser@gmail.com> writes:
Peter Dimov wrote:
the multi platform failures observed for grammar_mt_tests and owi_mt_tests seem to correlate to the recent thread lib update:
cxx: Error: ../boost/thread/pthread/thread.hpp, line 139: call of an object of a class type without appropriate operator() or conversion functions to pointer-to-function type (badcallclsobj) detected during instantiation of "void boost::thread::thread_data<F>::run() [with
F=boost::reference_wrapper<single_grammar_object_task>]" f(); ----------------^
Anyone knows what's going on?
I think I do. The new Boost.Threads implements the proposed standard interface where F is expected to be a function object; std::reference_wrapper is, but boost::reference_wrapper isn't. The old Boost.Threads did not suffer from this problem since it stored F in a boost::function, which automatically recognizes reference_wrapper and "dereferences" it before the call.
This can be fixed on the user side by wrapping the reference_wrapper in a boost::bind, or it can be fixed on the Boost.Threads side. The third option, making boost::reference_wrapper callable, is a very risky change that I would advise against.
I strongly object against silently changing the Boost.Thread interface/semantics. So I'ld vote for 2)
I've checked in an update to Boost.Thread that handles boost::reference_wrapper specially. Anthony -- Anthony Williams Just Software Solutions Ltd - http://www.justsoftwaresolutions.co.uk Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL
participants (5)
-
Anthony Williams
-
Hartmut Kaiser
-
Markus Schöpflin
-
Martin Wille
-
Peter Dimov