timeout.cr
Timeout.cr
Declarative timeout pattern for Crystal using select
keyword.
Installation
Add this to your application's shard.yml
:
dependencies:
timeout:
github: hugoabonizio/timeout.cr
Usage
require "timeout"
ch = Channel(Int32).new
spawn do
sleep 2
ch.send 1
end
select
when value = ch.receive
puts "Done!"
when Timeout.after(1.second)
puts "Timeout!"
end
Contributing
- Fork it ( https://github.com/hugoabonizio/timeout.cr/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- hugoabonizio Hugo Abonizio - creator, maintainer
Repository
timeout.cr
Owner
Statistic
- 9
- 1
- 0
- 1
- 0
- almost 8 years ago
- November 1, 2016
License
MIT License
Links
Synced at
Thu, 07 Nov 2024 01:08:32 GMT
Languages