Concurency wtf?

Prudence via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Sep 8 11:54:57 PDT 2015


I can't seem to receive certain messages, my code is very simple 
and it all works except for receiving:


in one thread I do


locate("MyMonitor").send(cast(shared)pt);

which sends the message(pt is a windows POINT structure).

In the MyMonitor spawned thread, I have


		while (true)
		{
			POINT y;
			receiveTimeout(100.msecs,
					(POINT p)
					{
						y = p;
					}
					);


			Thread.sleep(100.msecs);
			continue;
		}


Note that everything works except the matching in receiveTimeout. 
(I've tired various things and simplifications to no avail).

I can send simple types like int and bool. e.g., sending a 
literal works fine. My guess is the shared is causing problems 
but I've tried all common sense combinations. But I have to send 
shared, else send complains about sending unshared types.

Of course, the great thing is, all examples use literals and 
hence not real world examples(isn't that nice?).

Please don't ask me to provide source. The issue has nothing to 
do with the other code but specifically the TYPE that is being 
sent. Works for some types and not others. It is almost surely 
due to the shared issue, any ideas?




More information about the Digitalmars-d-learn mailing list