Overhead of synchronized class used in unshared situation

breezes wangyuanzju at gmail.com
Sun Nov 27 22:37:39 PST 2011


Thanks. It seems that I have to write two classes, one synchronized and one is not. Of course the
synchronized one should be the wrapper.

However, all members of a synchronized class are also shared. So I can not use the un-synchronized class
in the synchronized wrapper class directly. I found two ways to overcome this problem:
1. Cast away shared whenever using the wrapped un-synchronized object.
2. Define the wrapped un-synchronized object as __gshared.

Which way if more preferred?


More information about the Digitalmars-d-learn mailing list