concurrent.cr
Modern Adequate Any
New opportunities for concurrency tools in Crystal.
Large empty lots spacious directories available to build your dream home algorithm!
Space is filling up at (24k code bytes / 2 months) 0.004 bytes per second. Register your PR today!
©️ Real estate marketing association
Inspired by Erlang, Clojure, Scala, Haskell, F#, C#, Java, and classic concurrency patterns which inspired Ruby, which inspired this library.
Available classes:
More algorithms are coming. Contributions welcome.
Installation
-
Add the dependency to your
shard.yml
:dependencies: concurrent: github: didactic-drunk/concurrent.cr
-
Run
shards install
Usage
CountDownLatch
require "concurrent/count_down_latch"
fiber_count = 10
latch = Concurrent::CountDownLatch.new
10.times do
spawn do
# Do work
latch.count_down
end
end
latch.wait_count = fiber_count
latch.wait
Semaphore
require "concurrent/semaphore"
sem = Concurrent::Semaphore.new n
# spawn a lot of fibers
2000.times do
spawn do
sem.acquire do
...
end
end
end
Development
TODO Write development instructions here
Contributing
- Fork it (https://github.com/didactic-drunk/concurrent.cr/fork)
- Install a formatting check git hook (ln -sf ../../scripts/git/pre-commit .git/hooks)
- 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
- Click or Run
git shortlog --summary --numbered --email