crystal-wait-group
Version, currently master branch1 version
- master branchlatestMar 4, 2020
github.com/jasonrobot/crystal-wait-group
An implementation of WaitGroup modeled after golang's sync.WaitGroup
10 stars
0 dependents
License: MIT
Installation
# Add this to your shard.yml
dependencies:
crystal-wait-group:
github: jasonrobot/crystal-wait-group
branch: mastermaster is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
- Crystal
0.31.1- License
- MIT
- Author
- Jason Howell <jasonrobot64@gmail.com>
Dependencies
This version declares no dependencies.
README
# crystal-wait-group
This is a Crystal implementation of golang's sync.WaitGroup
There's probably still some work that needs to be done here, but it seems to work pretty well!
## Installation
1. Add the dependency to your `shard.yml`:
```yaml
dependencies:
crystal-wait-group:
github: jasonrobot/crystal-wait-group
```
2. Run `shards install`
## Usage
```crystal
require "crystal-wait-group"
```
To use like Go's WaitGroup, there are the `add`, `done`, and `wait` methods. They should work just as expected.
```
wg = WaitGroup.new
wg.add
spawn do
sleep 1
wg.done
end
wg.wait
```
As a fun crystal-style addition, there is also a `spawn` method which takes a block and spawns it in a fiber that is waited for by the WaitGroup.
```
wg = WaitGroup.new
wg.spawn do
sleep 1
end
wg.wait
```
## Development
All feedback is welcome! This is my first time playing with concurrency at this level, or doing low-level Crystal stuff, so there's gotta be room for improvment. The usage of `Intrinsics.pause` is taken from `Crystal::SpinLock`. Basically what I've gone for here is a version of SpinLock built around an atomic counter.
## Contributing
1. Fork it (<https://github.com/jasonrobot/crystal-wait-group/fork>)
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
## Contributors
- [Jason Howell](https://github.com/jasonrobot) - 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
- Mar 4, 2020
- Crystal
0.31.1- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/jasonrobot/crystal-wait-group
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 12, 2026
- Synced
- Aug 12, 2026
- Versions
- 1