Subclasses in std.concurrency.receive pattern match

Martin Nowak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jul 31 01:02:51 PDT 2015


On Friday, 31 July 2015 at 07:35:47 UTC, Marek Janukowicz wrote:
> So patten matching only works on type of containing variable, 
> not the type of the object itself. Is it possible to work 
> around this?

No, it would be very surprising if receive performed a dynamic 
downcast, and it's also somewhat expensive.
If you want that, do the downcast in your handler yourself.

> Won't the object get possibly GC'ed when it runs out of scope 
> in origin thread while handler thread still uses it?

No, the GC pauses and scans all threads for roots.




More information about the Digitalmars-d-learn mailing list