Mercurial > projects > dreactor
view dreactor/util/Emitter.d @ 13:8c9b1276f623 default tip
bug fixes
author | rick@minifunk |
---|---|
date | Sat, 20 Sep 2008 18:33:11 -0400 |
parents | dreactor/protocol/Emitter.d@d6a3cfe7c3de |
children |
line wrap: on
line source
module dreactor.util.Emitter; import tango.core.Thread; import dreactor.core.Task; import dreactor.protocol.IProvider; alias Message delegate() 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; EmitterDg callback; }