File tree Expand file tree Collapse file tree 2 files changed +15
-12
lines changed Expand file tree Collapse file tree 2 files changed +15
-12
lines changed Original file line number Diff line number Diff line change @@ -174,7 +174,6 @@ def try_rescue(ex) # :nodoc:
174
174
# @!visibility private
175
175
def work ( &handler ) # :nodoc:
176
176
begin
177
- should_notify = false
178
177
validator , value = mutex . synchronize { [ @validator , @value ] }
179
178
180
179
begin
@@ -187,18 +186,15 @@ def work(&handler) # :nodoc:
187
186
exception = ex
188
187
end
189
188
190
- mutex . synchronize do
191
- if !exception && valid
192
- @value = result
193
- should_notify = true
194
- end
189
+ mutex . lock
190
+ should_notify = if !exception && valid
191
+ @value = result
192
+ true
193
+ end
194
+ stashed = @stash . shift || ( @being_executed = false )
195
+ mutex . unlock
195
196
196
- if ( stashed = @stash . shift )
197
- @executor . post { work ( &stashed ) }
198
- else
199
- @being_executed = false
200
- end
201
- end
197
+ @executor . post { work ( &stashed ) } if stashed
202
198
203
199
if should_notify
204
200
time = Time . now
Original file line number Diff line number Diff line change @@ -160,6 +160,13 @@ def trigger_observable(observable)
160
160
subject . post
161
161
sleep ( 0.1 )
162
162
end
163
+
164
+ it 'works with ImmediateExecutor' do
165
+ agent = Agent . new ( 0 , executor : ImmediateExecutor . new )
166
+ agent . post { |old | old + 1 }
167
+ agent . post { |old | old + 1 }
168
+ agent . value . should eq 2
169
+ end
163
170
end
164
171
165
172
context 'fulfillment' do
You can’t perform that action at this time.
0 commit comments