zoidberg 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f631edac70299825464b22bcb61b054248eb0da
4
- data.tar.gz: 841685d0521b5b932c542db06d6d922a74d6c5ed
3
+ metadata.gz: 32acff92e97fb082892e250a4e672adf569a2648
4
+ data.tar.gz: bda6511a8e52e778d0aefc0b7ca3485321cd5aac
5
5
  SHA512:
6
- metadata.gz: c4da51a62307d58f60fb8947337f41e45786bcd3b364b6ada62c6f5f2c3dc225afd1193b8f020d4dcc00da6b9eab459520182ff4b6818993a753b67536c4c543
7
- data.tar.gz: 76b9c10d8f7896f66eb5640e7218bc84779e7df993dccb2807832b874729150c2e1979ca78601d9ad1d91429b2420839276c5c58716fd55011738d694018128a
6
+ metadata.gz: 07941b9b12c199d8d0ecd87992ccefd1bbf2794006e2b1d980306b683f260b362c6d9e9359ea6da68bdbb94aef9580ed76725429b65192ea2610d591669def79
7
+ data.tar.gz: 949f2f5f6e5886da400828ca3b1eef2f4c556f6d0e748e6dc6fa77a0a0a2c6111260c67b6fcf7c7f7a57675ac52d145eeb7fd456fbb3512212c216f770ad8259
@@ -1,3 +1,7 @@
1
+ # v0.2.2
2
+ * Remove async threads once they have reached completion
3
+ * Attempt to locate free worker in pool for async, random pick if none
4
+
1
5
  # v0.2.0
2
6
  * Update termination behaviors to ensure expected results
3
7
  * Provide and use flag for system shutdown to disable supervision
@@ -75,6 +75,12 @@ module Zoidberg
75
75
  true
76
76
  end
77
77
 
78
+ # Proxy async to prevent synchronized access
79
+ def async(*args,&block)
80
+ worker = _workers.detect(&:_zoidberg_available?) || _workers.sample
81
+ worker.send(:async, *args, &block)
82
+ end
83
+
78
84
  # Used to proxy request to worker
79
85
  def method_missing(*args, &block)
80
86
  worker = _zoidberg_free_worker
@@ -95,6 +95,15 @@ module Zoidberg
95
95
  true
96
96
  end
97
97
 
98
+ # Deregister a thread once it has completed
99
+ #
100
+ # @param thread [Thread]
101
+ # @return [TrueClass]
102
+ def _zoidberg_unthread(thread)
103
+ _raw_threads.delete(thread)
104
+ true
105
+ end
106
+
98
107
  # Aquire the lock to access real instance. If already locked, will
99
108
  # wait until lock can be aquired.
100
109
  #
@@ -39,9 +39,10 @@ module Zoidberg
39
39
  def method_missing(*args, &block)
40
40
  target._zoidberg_thread(
41
41
  Thread.new{
42
- origin_proxy._aquire_lock! if locked
43
- got_lock = locked
42
+ got_lock = false
44
43
  begin
44
+ origin_proxy._aquire_lock! if locked
45
+ got_lock = locked
45
46
  target.send(*args, &block)
46
47
  rescue Zoidberg::DeadException => e
47
48
  if(e.origin_object_id == target.object_id)
@@ -53,6 +54,7 @@ module Zoidberg
53
54
  raise
54
55
  ensure
55
56
  origin_proxy._release_lock! if got_lock
57
+ origin_proxy._zoidberg_unthread(Thread.current)
56
58
  end
57
59
  }
58
60
  )
@@ -1,4 +1,4 @@
1
1
  module Zoidberg
2
2
  # Current library version
3
- VERSION = Gem::Version.new('0.2.0')
3
+ VERSION = Gem::Version.new('0.2.2')
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zoidberg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Roberts
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-23 00:00:00.000000000 Z
11
+ date: 2015-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bogo