xthreads 0.1.4 → 0.1.5

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: b96555ceca710b36bf0791b733505f68ddc98d68
4
- data.tar.gz: af2183585144a0db3d60764635d0f955a9921b0c
3
+ metadata.gz: 2a6f41e03b20fbf799b6c71b541afb1830f37541
4
+ data.tar.gz: c031e94976c8aca16947fc93f01e9542f6571bf9
5
5
  SHA512:
6
- metadata.gz: a5c0f2439baf950e8f8c79e2b23e05ca8313c82196bac9baf1a22d043050a25817c13588fa2b3440b889b593dfb11ec236482d6cb5ed909cda2ed8b19e26e6d2
7
- data.tar.gz: c32d6d6f6db4e8b81c7f799e93e41d2751f6b897697b0766f3df0dbeb221bd8b33965116773a1a09d3a8a129bac8f7a0634c4a3acdff4c41177f802a2548f907
6
+ metadata.gz: eecb725f88e9794a33852d03c9cc53328628589cb65ae053eabea5e2f76b89e5728be9646e1784ebbec1ba4737c40b75e9f7e4f46872cd0333b6da662179ab66
7
+ data.tar.gz: b80306c3997abc8bb7975f63ff549e3027780aba2141483e4390a7b8851e8d45ec496b14ab79d3a0fd74ae0cdd734f1412897d08867d56d386f47a5d5def186f
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/xthreads.rb CHANGED
@@ -12,24 +12,28 @@ class XThreads < Hash
12
12
 
13
13
  attr_reader :state, :result
14
14
 
15
- def initialize(name, options={}, &blk)
15
+ def initialize(name, args, options={}, &blk)
16
16
  opts = {interval: 4, loop: true}.merge(options)
17
17
  @name = name
18
18
  @initialized = true
19
19
  @state = :stop
20
20
 
21
- @thread = Thread.new do
21
+ @thread = Thread.new(*args)do
22
22
  puts "#{name} created\n"
23
23
  Thread.current['name'] = name
24
24
  loop = true
25
25
  while loop == true do
26
-
26
+
27
+ #puts '@state : ' + @state.inspect
28
+
27
29
  if @state == :start then
28
- @result = blk.call
29
- @state = :dead
30
+ r = blk.call(args)
31
+ @result = r
32
+ Thread.current[:result] = r
33
+ #@state = :dead
30
34
  loop = false if opts[:loop] == false
31
35
  else
32
- puts 'stopped' unless @initialized == true
36
+ #puts 'stopped' unless @initialized == true
33
37
  @initialized = false
34
38
  end
35
39
 
@@ -68,9 +72,9 @@ class XThreads < Hash
68
72
  @threads[name]
69
73
  end
70
74
 
71
- def create_thread(name, options={}, &blk)
72
- cleanup
73
- @threads[name] = XThread.new name, options.merge(interval: 0, loop: false), &blk
75
+ def create_thread(name, args, options={}, &blk)
76
+ #cleanup
77
+ @threads[name] = XThread.new name, args, options.merge(interval: 0, loop: false), &blk
74
78
  @threads[name]
75
79
  end
76
80
 
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xthreads
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -29,7 +29,7 @@ cert_chain:
29
29
  8zMNMbb01yzfDo+1zSIq3Cu+Qiq22G7x9n8j2d09oc6xYiruzAYY8k51fyvuHxHp
30
30
  bzFPWySJi8C6r27XzfjSgV37vLLCUxsV
31
31
  -----END CERTIFICATE-----
32
- date: 2013-11-01 00:00:00.000000000 Z
32
+ date: 2013-11-29 00:00:00.000000000 Z
33
33
  dependencies: []
34
34
  description:
35
35
  email: james@r0bertson.co.uk
metadata.gz.sig CHANGED
Binary file