Git Product home page Git Product logo

forkme's Introduction

gem install forkme

A library for managing forks

The mother process spawns a fork and opens an io from the child to the parent and vice versa.
If the mother process dies, the children commit suicide. They also accept HUP and INT calls and die then as well.

Used like so,

forkme = Forkme.new(num_of_childs, Logger)
forkme.start do
  sleep 10
  puts "hey!!!"
end

The above code will continuously print "hey!!!". Once the child process has slept 10 seconds and printed "hey!!!" it will die and the mother process will start another to replace it.
You can start this in a thread if you'd like to have control back after spawning the children.
Thread.new do
  forkme.start do
    ...
  end
end

If you have to change the number of max forks forkme should spawn, it can be done
forkme = Forkme.new(num_of_childs, Logger)
forkme.start do
  forkme.max_forks = new_num_of_childs
  sleep 10
  ...do something...
end

Have fun and enjoy :]

forkme's People

Contributors

teubanks avatar

Stargazers

anewusername1 avatar  avatar

Watchers

anewusername1 avatar

Forkers

teubanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.