Ruby on Rails Concurrency Gem

24 Sep

I’ve just released a very alpha version of my Ruby on Rails concurrency Gem, Runner. The syntax is simple and doesn’t require any blocks. For example you could run a method in the background with as simple as:

Klass.spawn.my_method

Which forces “my_method” to be executed in the background.

Queue’ing methods

With Runner it’s also possible to queue calls which will be executed at a later given time. For example you would like to do some very CPU intensive, long running method to be executed daily at 12AM:

class User
def takes_long_time
2 + 2 # I 'm not kidding!
end
end

# somewhere in your code:
user = User.new
user.spawn(:method => :queue).takes_long_time # => The method is now queued and won't be run

# In a rake task witch is run by cron at night
runner = Runner::TaskSpawner.new
runner.start_handlers # => All queued tasks are now being forked and run asynch in the background

For more information and features about the Gem please go to the github repo.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.