simplepool
Version, currently master branch1 version
- master branchlatestApr 18, 2023
github.com/konovod/simplepool
Simple thread-safe pool for anything that is not thread-safe
0 stars
0 dependents
License: MIT
Installation
# Add this to your shard.yml
dependencies:
simplepool:
github: konovod/simplepool
branch: mastermaster is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
- Crystal
1.7.2- License
- MIT
- Author
- konovod
Dependencies
This version declares no dependencies.
README
simplepool
Simple thread-safe pool for anything that is not thread-safe.
Installation
-
Add the dependency to your
shard.yml:dependencies: simplepool: github: konovod/simplepool -
Run
shards install
Usage
require "simplepool"
# Note that `MyConnection.new` will be protected by mutex, so can be not thread-safe
pool = SimplePool(MyConnection).new { MyConnection.new(address, port) }
10.times do
spawn do
# get object from pool
conn = pool.get
work_with(conn)
# don't forget to return it
pool.return(conn)
end
end
10.times do
spawn do
# safe version as you don't need to explicitely return it
pool.use do |conn|
work_with conn
raise "error" # object will be returned to pool even after raise
end
end
end
Docs on API are available on https://konovod.github.io/simplepool
Contributing
- Fork it (https://github.com/konovod/simplepool/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
- konovod - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This branch
- Branch
master- Seen
- Apr 18, 2023
- Crystal
1.7.2- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/konovod/simplepool
Metadata
- Created
- Aug 16, 2026
- Updated
- Aug 16, 2026
- Synced
- Aug 16, 2026
- Versions
- 1