Large (>32 byte) concurrency messages

Ali Çehreli acehreli at yahoo.com
Fri Aug 9 08:45:51 PDT 2013


On 08/09/2013 03:17 AM, JR wrote:

 > On Thursday, 8 August 2013 at 21:16:36 UTC, David Nadlinger wrote:

 >> when taking a pointer to stack data
 >> (which is un- at safe), you have to take care not to escape it from the
 >> scope.
 >
 > Can I manually store it on the heap and let the garbage collector keep
 > it safe?

How about passing by-value? The following seems to work. (I used 
v2.064-devel-4203c06 but I don't know whether it is different on older 
compilers.)

// Receives by value:

	mixin MessageReaction.Print!(IrcEvent) immEvtPtr;

// Sends by value:

	IrcEvent e = fakeParser();
	p.send(e);

Ali



More information about the Digitalmars-d-learn mailing list