xthreads 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/xthreads.rb +8 -3
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2fd1d7150404eb82c1404d28bea6a962f3957cd
|
4
|
+
data.tar.gz: b0373bcdfd3ca3b334d46eff929b61faaa10c539
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ad823121794ea0899129963550c0a3d67a556f7cf092fbcce9aea7c550752d9b377c74bd883498254d7623589abf642ecebb008000b1d35c06cf930748b64a4
|
7
|
+
data.tar.gz: a72b66dcd110c33c7c8f4cd968cfbbea145ea86ce52e85b3a8226a320092ade15fb8ba20b57b55c4b92bcd0872586ded816214212a9284b560be9b98772700db
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/xthreads.rb
CHANGED
@@ -13,12 +13,15 @@ class XThreads < Hash
|
|
13
13
|
attr_reader :state, :result
|
14
14
|
|
15
15
|
def initialize(name, args, options={}, &blk)
|
16
|
+
|
16
17
|
opts = {interval: 4, loop: true}.merge(options)
|
18
|
+
@loop = opts[:loop]
|
19
|
+
|
17
20
|
@name = name
|
18
21
|
@initialized = true
|
19
22
|
@state = :stop
|
20
23
|
|
21
|
-
@thread = Thread.new(*args)
|
24
|
+
@thread = Thread.new(*args) {
|
22
25
|
puts "#{name} created\n"
|
23
26
|
Thread.current['name'] = name
|
24
27
|
loop = true
|
@@ -41,14 +44,16 @@ class XThreads < Hash
|
|
41
44
|
|
42
45
|
sleep opts[:interval]
|
43
46
|
end
|
44
|
-
|
47
|
+
}
|
48
|
+
|
45
49
|
|
46
50
|
end
|
47
51
|
|
48
52
|
def start
|
53
|
+
|
49
54
|
puts "#{@name} starting ..."
|
50
55
|
@state = :start
|
51
|
-
@thread.run
|
56
|
+
@thread.send @loop == true ? :join : :run
|
52
57
|
end
|
53
58
|
|
54
59
|
def stop
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|