Mercurial > projects > dreactor
view dreactor/protocol/Emitter.d @ 12:d6a3cfe7c3de
more stuff
author | rick@Macintosh.local |
---|---|
date | Wed, 27 Aug 2008 00:47:33 -0400 |
parents | |
children |
line wrap: on
line source
module Emitter import tango.core.Thread; import dreactor.core.Task; alias Message delegate(void) EmitterDg; class Emitter { public this(Task t, EmitterDg cb) { task = t; callback = cb; thread = new Thread(&run); thread.start(); } void stop() { running = false; } void stopNow() { thread.isDaemon(true); running = false; } private void run() { while(running) { Message msg = callback(); task.appendIVMessage(msg); } } Task task; Thread thread; bool running; EmitterCb callback; }