Boost logo

Boost :

From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2008-01-17 03:20:52

Gennadiy Rozental wrote:
> "Tobias Schwinger" <tschwinger_at_[hidden]> wrote in message
> news:fmkefr$cf3$
>>> For instance, the design
>>> could be made more flexible by allowing thread-safety to be specified as
>>> a
>>> policy (with appropriate default) or by delegating the responsibility to
>>> the
>>> wrapped type.
>> OK, FWIW policies complicate things. And what's their benefit here?
> I disagree. In general policies promote modularization. In this concrete
> case policy based solution would allow more flexibility in how "thread-safe"
> I want to be.

They often also promote over-complication:

Thread-safety that is more complex than applying a simple mutex is very
case-dependent and should be implemented manually.

>>> If BOOST_HAS_THREADS is defined, it looks as though I have no
>>> choice but to use mutexed instantiation and/or access. If I'm not
>>> interested in synchronised access, then the lease interface is useless.
>> Wrong:
>> The lease interface is useful to improves performance. The test whether
>> the Singleton has been initialized (which requires synchronization) can
>> be performed only once.
> The lease interface only improves preformance in your design. With Meyer's
> singleton instance() is as efficient. With any other solution that returns
> T&, I just need to store local referene to the target type.

Storing the instance is out of the question with automatic locking.

[... tons of text]


Boost list run by bdawes at, gregod at, cpdaniel at, john at