https://github.com/stemann/resourcepools.jl
https://github.com/stemann/resourcepools.jl
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/stemann/resourcepools.jl
- Owner: stemann
- License: mit
- Created: 2019-02-14T09:45:00.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T10:42:58.000Z (over 2 years ago)
- Last Synced: 2025-06-25T20:52:14.823Z (11 months ago)
- Language: Julia
- Size: 26.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ResourcePools
[](https://github.com/IHPSystems/ResourcePools.jl/actions/workflows/CI.yml?query=branch%3Amaster)
[](https://codecov.io/gh/IHPSystems/ResourcePools.jl)
[](https://github.com/invenia/BlueStyle)
ResourcePools is a Julia package that enables re-use of "expensive" resources, such as memory allocations, or database connections, by providing functionality for creating and managing pools of such resources. The management of resources is based on reference counting.
ResourcePools provides generic types `ResourcePool{T}`, and `PooledResource{T}`, as well as an array-specific type, `PooledArray{T,N}`.
ResourcePools is thread-safe.
## Usage
```julia
using ResourcePools
# Create a pool of 3 Int resources using a generator method for creating resources
p = ResourcePool{Int}(3, () -> 42)
# Get a resource from the pool
r = take!(p)
# Use the resource
# Return the resource to the pool
release!(p)
```