Skip to content

Instantly share code, notes, and snippets.

@showstopper
Created July 17, 2010 16:46
Show Gist options
  • Save showstopper/479639 to your computer and use it in GitHub Desktop.
Save showstopper/479639 to your computer and use it in GitHub Desktop.
use zeromq
import zeromq, threading/Thread, os/Time
me: Socket
Actor: class extends Thread {
ctx: Context
me: Socket
init: func(=ctx) {
me = Socket new(ctx, SocketType pair)
me bind("inproc://me")
}
start: func {
while (true) {
"Yay" println()
request := me recv()
printf("%s \n", request data())
Time sleepSec(1)
}
}
wait: func { }
}
main: func {
ctx := Context new(2)
me := Socket new(ctx, SocketType sub)
me bind("inproc://me")
actor := Actor new(ctx)
actor start()
while (true) {
"yao" println()
me send(Message new("hallo", "hallo" length(), null, null), SendRecvOption noBlock)
Time sleepSec(2)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment