module shaketest;
import tango.io.Stdout;
import shake.actor;
import shake.message;
/** A simple "report" */
class Report : Message {
public:
this(int smsg)
{
msg = smsg;
}
/** Handle things to print */
void handle(Actor a)
{
synchronized (Stdout) {
Stdout(cast(void*) a)(": ")(msg).newline;
}
}
private:
int msg;
}
int main()
{
int i;
// Make a bunch of reporters
Actor[] rs;
for (i = 0; i < 50; i++) {
Actor r = new Actor;
rs ~= r;
r.start();
}
// Then put them all in a delegater
Delegater d = new Delegater(rs);
// Then just start spewing messages
for (i = 0; i < 1000; i++) {
d.enqueue(new Report(i));
}
d.start();
// now encode one syncronously
synchronized (Stdout) {
Stdout("Sending synchronous message.").newline;
}
d.enqueueSync(new Report(1000000));
synchronized (Stdout) {
Stdout("Done with synchronous message.").newline;
}
return 0;
}