|
Threads-Devel : |
From: Anthony Williams (anthony_at_[hidden])
Date: 2006-03-02 02:45:50
Matt Hurd <matt.hurd_at_[hidden]> writes:
>>On Thursday 02 March 2006 08:50, Anthony Williams wrote:
> <snip>
>> The advantage is that you cannot statically initialize a critical section.
>>
>> Anthony
>
> You can statically initialise an object via its constructor where the
> constructor initialises the critcial section provided the initialisation is
> race free can't you?
>
> You always have the dependent use issue when you statically initialise mutexes
> as other static things can't rely on them due to the ordering problem.
If an object can be entirely statically initialized, or zero-initialized, then
there is no ordering problem or race condition. If the object requires dynamic
initialization (e.g. a constructor call) then there *is* an ordering problem.
That's my whole point --- critical sections require explicit initialization
via a constructor, whereas my basic_mutex does not.
Objects of static storage duration that require initialization via a
constructor are prone to ordering problems and race conditions. Objects of
static storage duration that can be static initialized are not subject to
either.
Anthony
-- Anthony Williams Software Developer Just Software Solutions Ltd http://www.justsoftwaresolutions.co.uk