nworkers.cr

test

nworkers.cr is an experimental library in Crystal programming language that allows you to change the number of worker threads at runtime.

See Crystal Forum : How to add command line options to specify the number of threads?

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      nworkers:
        github: kojix2/nworkers.cr
  2. Run shards install

Usage

This is an experimental library. It is intended for use where the number of workers is changed immediately after startup and not changed afterwards. For example, in a command line tool, where the number of threads is set as an option.

Here's an example:

require "nworkers"

# set the number of workers to 4
NWorkers.set_worker(4)

# add 2 more workers
NWorkers.add_worker(2)

# remove 1 worker
NWorkers.remove_worker

Documentation

Development

Contributing

  1. Fork it (https://github.com/kojix2/nworkers.cr/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

Contributions are welcome! Please feel free to submit a Pull Request if you find a bug or you want to propose a new feature.