Skip to content

Instantly share code, notes, and snippets.

@surma
Last active August 29, 2015 13:56
Show Gist options
  • Save surma/8984641 to your computer and use it in GitHub Desktop.
Save surma/8984641 to your computer and use it in GitHub Desktop.
type
TMsg = object
data : string
var
c : TChannel[TMsg]
t : TThread[void]
proc logger(){.thread.} =
echo("Logger start")
echo("c.peek() =", c.peek())
while c.peek() != -1:
echo("Receiving something")
var s = c.recv()
echo("Received: ", s.data, "\n")
echo("Logger done")
proc main() =
c.open()
createThread[void](t, logger)
c.send(TMsg(data: "hai"))
c.close()
t.joinThread()
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment