rbgo 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/lib/rbgo/corun.rb +26 -5
- data/lib/rbgo/version.rb +1 -1
- data/rbgo.gemspec +1 -1
- metadata +5 -6
- data/Gemfile.lock +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 113f0668f29ce9c2cc2bf6b030dc8595b48b568a33f6d6767009e5f636a781e5
|
4
|
+
data.tar.gz: 7b99d3977185488a7727afed6f0c36d4a1721cd0514e497d3a315277a4b1f76f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bed3889fec534a3bebad351ad0949b46ef56ad643a671666e5f9ce2eea0a1d4fb1338ff1523ac1e08e72ff820c15cae06150b2aab3b591a9a2221ed84111da2
|
7
|
+
data.tar.gz: e67e9b0dcedd5fcc3dbf9be97b04dee673da76b8cc0307df4aab938b01cb3b37e00ed4d7fc775bc1613479a1f10c182eb78e992b2ff0dc3cf6843107338cd10a
|
data/README.md
CHANGED
data/lib/rbgo/corun.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'thread'
|
2
2
|
require 'fiber'
|
3
|
-
require '
|
3
|
+
require 'system'
|
4
4
|
require 'singleton'
|
5
5
|
|
6
6
|
module Rbgo
|
@@ -18,10 +18,27 @@ module Rbgo
|
|
18
18
|
|
19
19
|
attr_accessor :args, :blk, :fiber
|
20
20
|
|
21
|
-
def initialize(*args, &blk)
|
21
|
+
def initialize(*args, new_thread: false, &blk)
|
22
22
|
self.args = args
|
23
23
|
self.blk = blk
|
24
|
-
|
24
|
+
if new_thread
|
25
|
+
Thread.new do
|
26
|
+
self.fiber = Fiber.new do |args|
|
27
|
+
blk.call(*args)
|
28
|
+
end
|
29
|
+
|
30
|
+
begin
|
31
|
+
while fiber.alive?
|
32
|
+
fiber.resume(*args)
|
33
|
+
end
|
34
|
+
rescue Exception => ex
|
35
|
+
self.error = ex
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
else
|
40
|
+
Scheduler.instance.schedule(self)
|
41
|
+
end
|
25
42
|
end
|
26
43
|
|
27
44
|
def perform
|
@@ -49,7 +66,7 @@ module Rbgo
|
|
49
66
|
attr_accessor :supervisor_thread
|
50
67
|
|
51
68
|
def initialize
|
52
|
-
self.num_thread =
|
69
|
+
self.num_thread = System::CPU.count || 8
|
53
70
|
self.thread_pool = []
|
54
71
|
|
55
72
|
self.msg_queue = Queue.new
|
@@ -188,7 +205,11 @@ module Rbgo
|
|
188
205
|
module CoRunExtensions
|
189
206
|
refine Object do
|
190
207
|
def go(*args, &blk)
|
191
|
-
CoRun::Routine.new(*args, &blk)
|
208
|
+
CoRun::Routine.new(*args, new_thread: false, &blk)
|
209
|
+
end
|
210
|
+
|
211
|
+
def go!(*args, &blk)
|
212
|
+
CoRun::Routine.new(*args, new_thread: true, &blk)
|
192
213
|
end
|
193
214
|
end
|
194
215
|
end
|
data/lib/rbgo/version.rb
CHANGED
data/rbgo.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
|
20
20
|
In MRI write program to run concurrently even not parallelly is also important.
|
21
21
|
END
|
22
|
-
s.add_dependency "
|
22
|
+
s.add_dependency "system", "~> 0.1.3"
|
23
23
|
s.files = `git ls-files`.split("\n")
|
24
24
|
s.license = 'MIT'
|
25
25
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbgo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wang Yin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: system
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.1.3
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.1.3
|
27
27
|
description: " Write concurrent program with Ruby in Golang style.
|
28
28
|
\ \n\n You can produce a light weight routine easily with a method
|
29
29
|
'go' and communicate with each routine by channel.\n\n In MRI
|
@@ -39,7 +39,6 @@ extra_rdoc_files: []
|
|
39
39
|
files:
|
40
40
|
- ".gitignore"
|
41
41
|
- Gemfile
|
42
|
-
- Gemfile.lock
|
43
42
|
- LICENSE
|
44
43
|
- README.md
|
45
44
|
- lib/rbgo.rb
|
data/Gemfile.lock
DELETED