comparison tango/example/cluster/qlisten.d @ 132:1700239cab2e trunk

[svn r136] MAJOR UNSTABLE UPDATE!!! Initial commit after moving to Tango instead of Phobos. Lots of bugfixes... This build is not suitable for most things.
author lindquist
date Fri, 11 Jan 2008 17:57:40 +0100
parents
children
comparison
equal deleted inserted replaced
131:5825d48b27d1 132:1700239cab2e
1 private import tango.core.Thread;
2
3 private import tango.util.log.Configurator;
4
5 private import tango.net.cluster.NetworkQueue;
6
7 private import tango.net.cluster.tina.Cluster;
8
9 /*******************************************************************************
10
11 Illustrates how to setup and use a Queue in asynchronous mode
12
13 *******************************************************************************/
14
15 void main ()
16 {
17 void listen (IEvent event)
18 {
19 while (event.get)
20 event.log.info ("received asynch msg on channel " ~ event.channel.name);
21 }
22
23
24 // join the cluster
25 auto cluster = (new Cluster).join;
26
27 // access a queue of the specified name
28 auto queue = new NetworkQueue (cluster, "my.queue.channel");
29
30 // listen for messages placed in my queue, via a delegate
31 queue.createConsumer (&listen);
32
33 // stuff something into the queue
34 queue.log.info ("sending three messages to the queue");
35 queue.put (queue.EmptyMessage);
36 queue.put (queue.EmptyMessage);
37 queue.put (queue.EmptyMessage);
38
39 // wait for asynchronous msgs to arrive ...
40 Thread.sleep (1);
41 }