Created
June 8, 2018 15:44
-
-
Save vaneyckt/bfcfddbcb8bae37d984dfc9fe05a1067 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
timeout_queue = TimeoutQueue.new | |
# blocking pop, empty queue - new data is added after 5s | |
Thread.new { sleep 5; timeout_queue << 'foobar' } | |
timeout_queue.pop # => waits for 5s for data to arrive, then returns 'foobar' | |
# blocking pop, empty queue - no new data is added | |
timeout_queue.pop(true, 10) # => raises ThreadError after 10s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment