A monitor for every object
"Jérôme M. Berger"
jeberger at free.fr
Sat Feb 5 00:00:31 PST 2011
Robert Jacques wrote:
> On Fri, 04 Feb 2011 17:23:35 -0500, Jérôme M. Berger <jeberger at free.fr>
> wrote:
>
>> Steven Schveighoffer wrote:
>>> D's monitors are lazily created, so there should be no issue with
>>> resource allocation.
>> What happens if two threads attempt to create a monitor for the
>> same object at the same time? Is there a global lock to avoid race
>> conditions in this case?
>>
>> Jerome
>
> Only the reference to the mutex is shared, so all you need in an atomic op.
This requires an atomic "if (a is null) a = b;". I did not know
that such a beast existed.
Jerome
--
mailto:jeberger at free.fr
http://jeberger.free.fr
Jabber: jeberger at jabber.fr
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20110205/3a2df032/attachment-0001.pgp>
More information about the Digitalmars-d
mailing list