remotable 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/remotable/nosync.rb +7 -1
- data/lib/remotable/version.rb +1 -1
- data/test/nosync_test.rb +12 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a78225c824ca7d175cf92ee2b9249c8f7cb564b40b9cb9e517afb23c60942a33
|
4
|
+
data.tar.gz: c9ccfb561fcf0589e907868f62bc0208677addd29be93bf69556d84e0a1e7997
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f59286e3951a20031978f3077f95a3d93fb9d4a69cbeb37d35ae7375233b10ddf9ed28f09c7a4d95aa8a2c38bc10b942b6f48f6a451a4a3c1222262f44d976c6
|
7
|
+
data.tar.gz: 114ee2c2f19c42c85b81e629a540aa8bfee1cc7b269462e62743e41ed09273627cdc2f21a8532a8d4f9cf681cc6bb9e74f9f46ebc91404c78aa67b181a8fc1d2
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
### 0.6.1
|
4
|
+
* **Bugfix** Tweaked the behavior of `Remotable.nosync?` to defer to a value set on the main thread if no value has been set for the current thread.
|
5
|
+
|
3
6
|
### 0.6.0
|
4
7
|
* **Bugfix** Completely removed dependence on `activeresource`'s `ThreadsafeAttributes`. This makes multithreaded behavior more deterministic and involves fewer edgecases, since things meant to be global state are reverted back to being so, while things meant to have a per-thread scope are constrained as they should be.
|
5
8
|
|
data/lib/remotable/nosync.rb
CHANGED
@@ -61,11 +61,17 @@ module Remotable
|
|
61
61
|
private
|
62
62
|
|
63
63
|
def _nosync
|
64
|
-
Thread.current.thread_variable_get "remotable.nosync.#{self.object_id}"
|
64
|
+
return Thread.current.thread_variable_get "remotable.nosync.#{self.object_id}" if nosync_defined_on?(Thread.current)
|
65
|
+
return Thread.main.thread_variable_get "remotable.nosync.#{self.object_id}" if nosync_defined_on?(Thread.main)
|
65
66
|
end
|
66
67
|
|
67
68
|
def _nosync=(value)
|
68
69
|
Thread.current.thread_variable_set "remotable.nosync.#{self.object_id}", value
|
70
|
+
Thread.current.thread_variable_set "remotable.nosync.#{self.object_id}.defined", true
|
71
|
+
end
|
72
|
+
|
73
|
+
def nosync_defined_on?(thread)
|
74
|
+
!!thread.thread_variable_get("remotable.nosync.#{self.object_id}.defined")
|
69
75
|
end
|
70
76
|
|
71
77
|
end
|
data/lib/remotable/version.rb
CHANGED
data/test/nosync_test.rb
CHANGED
@@ -48,6 +48,18 @@ class NoSyncTest < ActiveSupport::TestCase
|
|
48
48
|
assert_equal true, Tenant.nosync?
|
49
49
|
end
|
50
50
|
|
51
|
+
test "nosync? should defer to the main thread's value if set there but not on the current thread" do
|
52
|
+
Remotable.nosync!
|
53
|
+
subthread = Thread.new do
|
54
|
+
assert Remotable.nosync?
|
55
|
+
Remotable.reset_nosync!
|
56
|
+
refute Remotable.nosync?
|
57
|
+
Thread.stop
|
58
|
+
end
|
59
|
+
sleep 0.1 while subthread.status != "sleep"
|
60
|
+
assert Remotable.nosync?
|
61
|
+
end
|
62
|
+
|
51
63
|
|
52
64
|
|
53
65
|
# ========================================================================= #
|