Skip to content

Instantly share code, notes, and snippets.

@kedebug
Created July 23, 2014 09:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kedebug/eddfc8a9e981c6f67c8d to your computer and use it in GitHub Desktop.
Save kedebug/eddfc8a9e981c6f67c8d to your computer and use it in GitHub Desktop.
select
(define chan-1 (make-chan))
(define chan-2 (make-chan))
(go (chan<- chan-1 'hello-chan-1))
(go (chan<- chan-2 'hello-chan-2))
; sleep for 20 millisecond
(sleep 20)
(select
((<-chan chan-1))
((<-chan chan-2))
(default 'hello-default))
(close-chan chan-1)
(close-chan chan-2)
; the output will be randomized: hello-chan-1 or hello-chan-2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment