0.0
No commit activity in last 3 years
No release in over 3 years
This is a very simple task list library that I use in a bunch of other places.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.16
~> 5.0
~> 10.0
 Project Readme

Swiftcore::Tasks

This little library encapsulates a very simple task queue implementation. Tasks have a priority, and an object that responds to #call.

A TaskList is a set of Task objects that it orders according to priority.

The Tasklist allows running the whole queue of tasks, or running just a single task at a time.

If any Task returns a TaskList, that TaskList gets merged into the parent's list of tasks.

Installation

Add this line to your application's Gemfile:

gem 'swiftcore-tasks'

And then execute:

$ bundle

Or install it yourself as:

$ gem install swiftcore-tasks

Usage

result_list = []
list = Swiftcore::Tasks::TaskList.new
list << Swiftcore::Tasks::Task.new(4) { result_list << 3 }
list << Swiftcore::Tasks::Task.new(2) do
  sublist = Swiftcore::Tasks::TaskList.new
  sublist << Swiftcore::Tasks::Task.new(3) { result_list << 2 }
  sublist << Swiftcore::Tasks::Task.new(5) { result_list << 5 }
  sublist
end
list << Swiftcore::Tasks::Task.new(1) { result_list << 1 }

list.run
result_list == [1,2,3,5]

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/swiftcore-tasks.

License

The gem is available as open source under the terms of the MIT License.