pthread 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dafcdd2900f027b28215e12e83f2aa4aeff4a59c
4
- data.tar.gz: 31fa0fab9742a9c6fe677e62a6be238f89761591
3
+ metadata.gz: ab2e480b2458075f38532a9e4d66ed2432e71402
4
+ data.tar.gz: ab4a5edef41900153124ffa68173570b3d713e53
5
5
  SHA512:
6
- metadata.gz: 9453e1c25209cb0d5ecabf94b5c5323b7bd7f7527d7a7fd20f3ff28b18c81ea095c561e6159ffd02edc527cfd1cb8f67457295f4dcf402b57b2f59cd33a9df2d
7
- data.tar.gz: 882c89a3653ce66bb42acc97d94c7735d9a50df5607d198a565036d35cd9eb19ae74b9621ad3037b5ad7fa9c75bba09197011c940b8d670650a5ee0c5c554e96
6
+ metadata.gz: c431e34a38e3c2007c8ca1e5ed96d09d43ad5c0bc21af3b2f0b188181b4a58bcb472b4b478771d7093af2a834d24a0830b5b3e5b314ab0f3b59862da4642e03a
7
+ data.tar.gz: 0f7c4a73d6274c2a15cd4c7034d7c86a2fd7012213be9e9647cfa7aec1d7cb3cb13afe607dbecdd2cbec2ce9b3ee1313d4ec40f533d43cf61955059ec3cc6bec
@@ -4,15 +4,15 @@ module Pthread
4
4
 
5
5
  # The +Pthread+ class is the main class that users work with.
6
6
  # It used for creating forks to be executed in a separate processes
7
- # including other machines
7
+ # including on remote machines.
8
8
  class Pthread
9
9
 
10
10
  @@ts = Rinda::TupleSpace.new
11
11
  @@pids = []
12
12
 
13
- # Starts the drb server
13
+ # Starts the drb server.
14
14
  #
15
- # @param [ String ] that contains host url and port
15
+ # @param [String] host that contains host url and port.
16
16
  #
17
17
  # @example Start service
18
18
  # Pthread::Pthread.start_service '192.168.1.100:12345'
@@ -21,16 +21,15 @@ module Pthread
21
21
  DRb.start_service("druby://#{@@host}", @@ts)
22
22
  end
23
23
 
24
- # Adds executors on the same machine as the main programm
24
+ # Adds executors on the same machine as the main programm.
25
25
  #
26
- # @param [ FixNum ] amount of executors to start
27
- # @param [ Symbol, String ] name of the queue for executors to be attached to
26
+ # @param [FixNum] count amount of executors to start.
27
+ # @param [Symbol, String] queue name of the queue for executors to be attached to.
28
28
  #
29
29
  # @example Add executors without a queue
30
30
  # Pthread::Pthread.add_executors 5
31
31
  # @example Add executors for specific queue
32
32
  # Pthread::Pthread.add_executors 5, :tasks
33
-
34
33
  def self.add_executors(count = 1, queue=nil)
35
34
  count.times do
36
35
  @@pids << fork do
@@ -40,19 +39,19 @@ module Pthread
40
39
  end
41
40
  end
42
41
 
43
- # Adds a single executor on the same machine as the main programm
42
+ # Adds a single executor on the same machine as the main programm.
44
43
  #
45
- # @param [ Symbol, String ] name of the queue for executor to be attached to
44
+ # @param [Symbol, String] queue name of the queue for executor to be attached to.
46
45
  #
47
- # @example Add executor without a queue
46
+ # @example Add an executor without a queue
48
47
  # Pthread::Pthread.add_executor
49
- # @example Add executor for specific queue
48
+ # @example Add an executor for a specific queue
50
49
  # Pthread::Pthread.add_executor, :tasks
51
50
  def self.add_executor(queue=nil)
52
51
  add_executors(1, queue)
53
52
  end
54
53
 
55
- # Kills all launched executors on this machine
54
+ # Kills all launched executors on this machine.
56
55
  #
57
56
  # @example Add executors without a queue
58
57
  # Pthread::Pthread.kill_executors
@@ -61,9 +60,9 @@ module Pthread
61
60
  @@pids = []
62
61
  end
63
62
 
64
- # Initializes new pthread and schedules execution of the job
63
+ # Initializes new pthread and schedules execution of the job.
65
64
  #
66
- # @param [ Hash ] should containt :code, :context and optionally :queue
65
+ # @param [Hash] job should contain :code, :context and optionally :queue
67
66
  #
68
67
  # @example Initialize new parrallel job
69
68
  # pthread = Pthread::Pthread.new queue: 'tasks', code: %{
@@ -74,25 +73,26 @@ module Pthread
74
73
  end
75
74
 
76
75
 
77
- # Returns value of a pthread
76
+ # Returns value of a pthread.
78
77
  #
79
- # @note If value if not yet calculated will block the execution
80
- # @note If pthread resulted in an exception it will be raised
78
+ # @note If value is not yet calculated it will block the execution.
79
+ # @note If pthread resulted in an exception it will be raised.
81
80
  #
82
- # @example pthread.value
81
+ # @example
82
+ # pthread.value
83
83
  #
84
- # @return [ Object ] value of a pthread
84
+ # @return [Object] value of a pthread.
85
85
  def value
86
86
  raw_value.is_a?(StandardError) ? raise(raw_value) : raw_value
87
87
  end
88
88
 
89
89
  private
90
90
 
91
- # Returns raw value of a pthread even if it was an exception
91
+ # Returns raw value of a pthread even if it was an exception.
92
92
  #
93
- # @note If value if not yet calculated will block the execution
93
+ # @note If value is not yet calculated will block the execution.
94
94
  #
95
- # @return [ Object ] raw value of a pthread
95
+ # @return [Object] raw value of a pthread.
96
96
  def raw_value
97
97
  @raw_value ||= @@ts.take([self.object_id, nil])[1]
98
98
  end
@@ -8,10 +8,10 @@ module Pthread
8
8
 
9
9
  # Initliazes new executor.
10
10
  #
11
- # @param [ String ] DRB host that has main programm running
12
- # @param [ String, Symbol ] optinal queue name to attach executor
11
+ # @param [ String ] host DRB host that has main programm running.
12
+ # @param [ String, Symbol ] queue optinal queue name to attach executor.
13
13
  #
14
- # @example Connect to remote Drb service
14
+ # @example Connect to remote dRb service
15
15
  # Pthread::PthreadExecutor.new '192.168.1.100:12345', :tasks
16
16
  def initialize(host, queue=nil)
17
17
  DRb.start_service
@@ -1,3 +1,3 @@
1
1
  module Pthread
2
- VERSION = '0.0.8'
2
+ VERSION = '0.0.9'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pthread
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikita Cernovs