On Saturday, June 01, 2013 10:03:28 Andrey wrote:
> On Saturday, 1 June 2013 at 00:58:00 UTC, Jonathan M Davis wrote:
> > On Friday, May 31, 2013 23:26:19 Anthony Goins wrote:
> >> To create a shared object you need shared this ctor.
> >> 
> >> immutable this() for immutable,
> >> 
> >> and const this() for const.
> >> 
> >> Check out the change log. #2 on the list.
> > 
> > Either that or you create it as thread-local and cast to shared.
> > 
> > - Jonathan M Davis
> 
> Does it mean, that to create shared Mutex or shared Socket for
> example, I have to use next construction:
> 
>       shared Socket socket = cast(shared Mutex)(new Socket());
> 
>       shared Mutex m = cast(shared Mutex)(new Mutex());

Given the lack of shared constructors, yes - though you should probably write 
it more like

    auto mutex = cast(shared)new Mutex;
    auto socket = cast(shared)new Socket;

since then you don't have to worry about accidentally changing the base type 
(like you did with the Socket), and you don't have to write the type multiple 
times.

- Jonathan M Davis

Reply via email to