0.0
Low commit activity in last 3 years
A long-lived project that still receives updates
Create threads, with an upper bound on how many can exist at the same time.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

ThreadPuddle

Gem Version Test Contributor Covenant

Like a smaller, lamer thread pool.


Public Class Methods

ThreadPuddle.new(capacity, klass=Thread)

Creates a new ThreadPuddle object, with a fixed capacity.

To use with a different threading model, specify a different klass, for example:

tp = ThreadPuddle.new c, ForkingThread

Public Instance Methods

tp.capacity → int

Retrieves the ThreadPuddle object's capacity.

tp.size → int

Number of threads currently occupying the puddle.

tp.blocktp

Blocks execution of the calling thread until there's a free slot in the puddle.

WARNING: there is no guarantee this will ever return.

tp.spawn(*args) {|*args| ... } → Thread

Spawns a new thread in the puddle.

If the puddle is full, this call blocks.

 @yields *args
 @see ThreadPuddle#block
 @return the new Thread object

tp.jointp

Waits for all threads in the puddle to join.

 @return this ThreadPuddle object

tp.kill → int

Kills all threads in the puddle.

 @return the number of threads killed

Contributing

We require all contributors to comply with the Developer Certificate of Origin. This ensures that all contributions are properly licensed and attributed.

Contributor Code of Conduct

This repository is subject to a Contributor Code of Conduct adapted from the Contributor Covenant, version 3.0, available at https://www.contributor-covenant.org/version/3/0/

Licence

This project is licensed under the ISC licence. See LICENSE for details