Any chance to avoid monitor field in my class?

Yuriy via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 8 10:21:07 PDT 2014


On Thursday, 8 May 2014 at 14:57:37 UTC, Steven Schveighoffer 
wrote:
> The de-facto minimum size of a class is 16 bytes, due to the 
> minimum block size of the heap.
>
> 8 bytes vtbl pointer on 64-bit systems would still allocate 
> into 16-byte blocks.
>
> -Steve

Yes, but still the question remains open for non-empty classes 
(e.g. want to use a 64bit useful payload), and for _emplacing_ 
any classes anywhere (e.g. on stack).

Afaiu, there's no solution except for declaring extern(C++) (yes, 
i know, it's a hack), and it will not work, if a class is 
templated on something which can not be cpp-mangled. So the 
question is: is there any reason why this is not possible? I 
mean, maybe this question was closed long before.

Also, do shared classes actually require monitors?


More information about the Digitalmars-d-learn mailing list