abundance 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/abundance.rb +25 -29
  2. data/lib/toolshed.rb +2 -8
  3. metadata +2 -2
data/lib/abundance.rb CHANGED
@@ -1,41 +1,37 @@
1
1
  # This class provides a mean to parallelize the execution of your program processes.
2
- # It is a process queue, named the Garden, with concurrent workers, named Rows, all this getting orchestrated by a Gardener.
2
+ # Based on the low maintenance Gardener,Garden,Seed natural design pattern.
3
3
  #
4
- # Its characteristics are:
5
- # * concurrent
6
- # * non-blocking
7
- # * simple
8
- # * pure ruby
9
- # * serialization friendly
10
- #
11
- # It:
12
- # * scales to multi core
13
- # * is intended for batch processing or other parallel ready operations
14
- # * can boost you program's performance
4
+ # Its for:
5
+ # * forking otherwise blocking loops in a non-blocking fashion
6
+ # * a simple abstraction for loopback communication with a forked execution
7
+ # * concurrent batch processing
8
+ # * scaling process intensive computations to multi-core parallel execution
15
9
  #
16
10
  # And not:
17
11
  # * a replacement for Thread.new invocations
18
12
  # * a replacement for Thread friendly programming languages like Erlang
19
13
  #
14
+ # Its initial implementation uses:
15
+ # * pure ruby
16
+ # * standard forks as mean to parallel non-blocking execution
17
+ # * fast UDP loopback sockets for process fork communication.
18
+ # * serialization friendly communication with process forks
19
+ # * a tier queuing fork, as a packet control middle man between process forks and the non-blocking process client
20
+ # * an elemental namespace: a process queue, named the Garden, with concurrent workers, named Rows, all this getting orchestrated by a Gardener.
20
21
  #
21
- # Based on Gardener,Garden,Seed natural design patern
22
- #
23
- # While there should be no use for this kind of class in most programs, there are some occasions where processes
24
- # cannot live inside serialized execution without blocking. The built in threading model can save your execution in many occasions, but in many case green threading is not enough, or simply just won't work.
25
- # For a nice explanation on the subject of ruby green threading, you can refer to: http://www.igvita.com/2008/11/13/concurrency-is-a-myth-in-ruby/
22
+ # ///////////////////////////////////////////////////////////////////////////////////////
26
23
  #
27
- # Abundance is by no mean intended to equal or compete with the tools mentionned in the article, its rather a different
28
- # approach on the same problem. I hope it will inspire some of you to hack out something that works even better,
29
- # and hopefully, eventually this tool will become obsolete because Ruby will get concurency built in.
30
- #
31
- # So, the approach here is really simple, you require abundance in your program.
32
- # Then ask the Abundance.gardener class method to build you a garden built with a garden patch block you provide as part of the invocation.
33
- # This garden patch block includes an initialization block, which may be empty,
34
- # and the invocation of the Abundance.grow class method, the perpetual seed ready patch garden.
35
- # It becomes the threaded looping object, growing concurently on garden patch row forks.
24
+ # Quick Start:
36
25
  #
37
- # The gardener objected is then available to seeds and harvest the multiple garden patch row forks,
38
- # allowing you to cultivate parallel garden rows where your seeds sprout till fruitful harvest time comes.
26
+ # 1. gem install abundance
27
+ # 2. require abundance
28
+ # 3. use the Abundance.gardener method to define your forking process. Its attached block IS THE FORK. Its return value IS YOUR CLIENT INSTANCE.
29
+ # 4. Abundance.gardener has simple commodities:
30
+ # * infinite loop inside Abundance.grow method's block
31
+ # * initialisation before Abundance.grow invocation, just put it there... you can use Abundance.init_status if you need init confirmation from the forks, otherwise don't bother.
32
+ # * reader and sender for socket communication with your client. seed.sprout reads, seed.crop sends.
33
+ # 5. use the client to communicate with forks: client.seed sends, client.harvest reads.
34
+ # 6. for detailed client docs: http://abundance.rubyforge.org/ruby-doc/classes/Gardener.html , and full docs: http://abundance.rubyforge.org/ruby-doc/
39
35
  #
40
36
  # Author:: lp (mailto:lp@spiralix.org)
41
37
  # Copyright:: 2008 Louis-Philippe Perron - Released under the terms of the MIT license
@@ -55,7 +51,7 @@ class Abundance
55
51
  # * :rows = garden rows number, the number of concurent threads
56
52
  # * :init_timeout = allow to pause execution to allow for larger gardens to initialize
57
53
  # === Example
58
- # gardener = Abundance.gardener( :block_size => 8192, :rows => 2, :init_timeout => 2) do
54
+ # gardener = Abundance.gardener( :wheelbarrow => 8192, :rows => 2, :init_timeout => 2) do
59
55
  #
60
56
  # processor = SpecialProcess.new
61
57
  # if processor.started_successfully?
data/lib/toolshed.rb CHANGED
@@ -20,15 +20,9 @@ module Toolshed
20
20
  def Toolshed.available_port
21
21
  port = @@start_port + 1
22
22
  catch :scan_port do
23
+ stat = `netstat`
23
24
  loop do
24
- begin
25
- socket = UDPSocket.new
26
- socket.connect(UDP_HOST,port)
27
- socket.send('',0)
28
- response,address = socket.recvfrom(1024)
29
- rescue Errno::ECONNREFUSED
30
- throw :scan_port
31
- end
25
+ throw :scan_port unless stat =~ /localhost\.#{port}/
32
26
  port += 1
33
27
  end
34
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abundance
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Louis-Philippe Perron
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-23 00:00:00 -05:00
12
+ date: 2009-01-10 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15