Boost logo

Boost :

From: Andrey Semashev (andysem_at_[hidden])
Date: 2007-02-03 19:26:40


Hello Steven,

Sunday, February 4, 2007, 2:09:37 AM, you wrote:

> AMDG

>> > line 912
>> > template< typename EventT >
>> > static state_dispatcher< EventT > const& get_state_dispatcher()
>> > {
>> > static const state_dispatcher< EventT > dispatcher;
>> > return dispatcher;
>> > }
>> > function static is not thread safe.
>>
>> It doesn't need to be. The state_machine class is intended to be used
>> in single-thread context. Once you have to access the machine from
>> multiple threads you should use locking_state_machine which
>> synchronizes on "process" function calls which is the only way
>> "get_state_dispatcher" gets called.

> Unfortunately, it isn't that simple. The dispatcher
> is shared by all state machines of the same type.
> Therefore even apparently unrelated machines can
> attempt to initialize it concurrently.

Yes, you're right here. But there's nothing really dangerous in
running state_dispatcher constructor more than once concurrently. I'll
see what I can do about it, just to be on the safe side.

-- 
Best regards,
 Andrey                            mailto:andysem_at_[hidden]

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk