[dmd-concurrency] Sending mesages to non-listening threads

Michel Fortin michel.fortin at michelf.com
Wed Jan 13 13:31:19 PST 2010


Le 2010-01-13 à 13:57, Sean Kelly a écrit :

>> GUI frameworks already have their own message passing system (for events), and their own event loops. Could there be a way to attach a customized "passer" function which would make the sending thread pass messages in a special way? This could allow messages to be sent to GUI threads by wrapping them in a GUI event. It'd simplify things from the worker thread point of view, which wouldn't have to mess with GUI stuff.
> 
> For GUI events, it's more likely that you'd have a thread waiting for those messages and then repackaging and resending them using the D model.

I was speaking of the reverse: sending D messages to a GUI thread having its own event loop (for instance after some work is done):

	// Executed in GUI thread
	void onClick() {
		spawn(&doWork, "work done");
	}
	void onMessage(string message) {
		if (message == "work done") {
			/* do something */
		}
	}

	// Executed in worker thread
	void doWork(string doneMessage) {
		// working here.
		send(mainTid, doneMessage);
	}

The idea is to not have to write GUI-specific code in doWork.


-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/





More information about the dmd-concurrency mailing list