asynchronous 3.0.0.pre.pre → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzI1NjQ3MTczMjQ3YjNhNThlNjY4ZDZiMjA0MmI0MWNiYzgxODJlNw==
4
+ MWRlMTE2ZjM5MmYyYjRiN2I3NGIyYjJhMTdmNGY1NzcxNjMxMGJjMg==
5
5
  data.tar.gz: !binary |-
6
- ZjAyZTNlNDYwZWY5NTJlOWViMWFmYTYzYjY3ZmEwNWQ5NmJhNWNkMg==
6
+ OGNlZWE3MjliNGRhMzY3NGEzZTZkMGE4M2Q3NTExZGU0NGY0OWNhMQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YjZjY2FiOWY3YzFmNjk0ZDRhNjVjZmQwYzc1NjdiOWEwMzVkZmI3MWY3NTg1
10
- NDFkM2E5Njg2ZGZkMjQ0MjBmZmU1YTliYTk0MTc0YzEyYTZmZmU0MGJlNzM0
11
- OWE4ZTdmMzIxNTViM2VkNzc0YzljNWJkOTg2Mzk5OTE5NTljZDE=
9
+ MTY3MmUyNTI2ODkxODMzZGEwNDdkMDI2YzY1Y2Y0MDZlOWUyOTM0NDI0MDEx
10
+ YjMzN2U3NTBhNjMzNGM4Y2I1ODI1MDBhNTgyMTg2NzQ1YWM5YzM3MDhlNWIw
11
+ ZDBiOTlkMjI2MTM4OTcwYTg0YjA3YWNlOTlmZGRhN2E3MWI2NzI=
12
12
  data.tar.gz: !binary |-
13
- Y2Y1MmY4NGRkMTJlYzU2NGU4ZjJhODNkMTNiMjEwNDQ4Y2QxYTc2YWZiNjg4
14
- YzM2NDc4ZjM0Njk5MTE5YzFjMDg4NGNlOWViM2VmNGU3MWMzZDliODY5OGJi
15
- ZjcwNWQ0ODc2YmIxMjcwZjBhNDY3NjMwZDNhODM0MGI5YjgyZTk=
13
+ NDRlMmNhODk3NDQ0YjkwNWY4MzJiNDNiMDQwZTg3YjNkNDE5Yzg3ZTQwYTRk
14
+ OWNiZWRjZjg1NGMwODhmODE3OGU2NDNhYjQ5M2UwMTI4MzA2NWM4ZDc5OWRj
15
+ ZTdhNmUxZTRmMDI5NmZjNmFjYWRiOTIwMGZmYjczNDgxYjU1YmM=
data/README.md CHANGED
@@ -160,3 +160,17 @@ Kernel holding on Native threads with pipes can choke up
160
160
  * direct sleep commands can do this on multiple native threads
161
161
  ** hard processing load not like that, only kernel sleep
162
162
 
163
+ SharedMemory objects not updating on chain method obj manipulation
164
+
165
+ ```ruby
166
+ shared_memory.var= {'jobs'=>[]}
167
+
168
+ {'jobs'=>[]}['jobs'].push 'data' #> {'jobs'=>[]}
169
+
170
+ workaround is like that:
171
+
172
+ local_variable= {'jobs'=>[]}
173
+ local_variable['jobs'].push('data')
174
+
175
+ shared_memory.var= local_variable
176
+ ```
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.0-pre
1
+ 3.0.1
@@ -0,0 +1,54 @@
1
+ require_relative "../lib/asynchronous"
2
+
3
+ shared_memory.ruby_worker_jobs= Array.new
4
+ shared_memory.static_variables.push :ruby_worker_jobs
5
+
6
+ class Worker
7
+
8
+ def self.do_some_hard_work! *args
9
+
10
+ puts "heavy db load job here with params #{args.inspect}"
11
+ #some brutal DB work here
12
+
13
+ end
14
+
15
+ def self.add_job *array
16
+ shared_memory.ruby_worker_jobs.push array
17
+ end
18
+
19
+ end
20
+
21
+
22
+ async :OS do
23
+
24
+ loop do
25
+
26
+ unless shared_memory.ruby_worker_jobs.empty?
27
+
28
+ puts "job to do again..."
29
+ job= shared_memory.ruby_worker_jobs.pop
30
+
31
+ model_name = job.shift
32
+ method_name = job.shift
33
+
34
+ model_name.__send__(method_name,*job)
35
+
36
+ puts "everything is done, so... nothing to do here... *sigh*"
37
+
38
+ else
39
+ sleep 0.1
40
+ end
41
+
42
+
43
+ end
44
+
45
+ end
46
+
47
+
48
+
49
+ loop do
50
+
51
+ sleep 6
52
+ Worker.add_job Worker,:do_some_hard_work!,{random: Random.srand}
53
+
54
+ end
@@ -9,6 +9,9 @@ module Asynchronous
9
9
  # when you need to update objects in the memory use :concurrency
10
10
  class Parallelism < Asynchronous::CleanClass
11
11
 
12
+ @@pids ||= []
13
+ @@motherpid ||= $$
14
+
12
15
  def asynchronous_fork callable
13
16
  return ::Kernel.fork do
14
17
 
@@ -53,9 +56,6 @@ module Asynchronous
53
56
 
54
57
  def initialize callable
55
58
 
56
- @@pids ||= []
57
- @@motherpid ||= $$
58
-
59
59
  @comm_line = ::IO.pipe
60
60
  @value = nil
61
61
  @read_buffer = nil
@@ -40,16 +40,12 @@ module Asynchronous
40
40
  def asynchronous_set_value obj
41
41
  return @data.write_object obj
42
42
  end
43
-
44
- def asynchronous_set_value= obj
45
- self.asynchronous_set_value(obj)
46
- end
43
+ alias :asynchronous_set_value= :asynchronous_set_value
47
44
 
48
45
  def asynchronous_get_value
49
46
  return @data.read_object
50
47
  end
51
48
 
52
-
53
49
  def method_missing(method, *args, &block)
54
50
 
55
51
  #::Kernel.puts "method: #{method}, #{args}, #{block}"
@@ -76,6 +72,7 @@ module Asynchronous
76
72
  end
77
73
 
78
74
  return_value= new_value.__send__(method,*args,&block)
75
+
79
76
  unless new_value == original_value
80
77
  asynchronous_set_value new_value
81
78
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asynchronous
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.pre.pre
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Luzsi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-13 00:00:00.000000000 Z
11
+ date: 2014-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: process_shared
@@ -57,6 +57,7 @@ files:
57
57
  - examples/array_of_value_with_native_threads.rb
58
58
  - examples/async_patterns.rb
59
59
  - examples/no_zombie_test.rb
60
+ - examples/ruby_worker.rb
60
61
  - examples/shared_memory1.rb
61
62
  - examples/shared_memory2.rb
62
63
  - files.rb
@@ -80,9 +81,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
80
81
  version: '0'
81
82
  required_rubygems_version: !ruby/object:Gem::Requirement
82
83
  requirements:
83
- - - ! '>'
84
+ - - ! '>='
84
85
  - !ruby/object:Gem::Version
85
- version: 1.3.1
86
+ version: '0'
86
87
  requirements: []
87
88
  rubyforge_project:
88
89
  rubygems_version: 2.2.1