lib/alexandria/execution_queue.rb in alexandria-book-collection-manager-0.7.5 vs lib/alexandria/execution_queue.rb in alexandria-book-collection-manager-0.7.6
- old
+ new
@@ -61,14 +61,15 @@
end
return if ary.nil?
id, procedure, args, need_retval = ary
retval = procedure.call(*args)
- if need_retval
- @protect_pending_retvals.synchronize do
- @pending_retvals << [id, retval]
- end
+
+ return unless need_retval
+
+ @protect_pending_retvals.synchronize do
+ @pending_retvals << [id, retval]
end
end
def stop
@@current_queue = nil
@@ -79,17 +80,17 @@
def push(procedure, args, need_retval = false)
@protect_pending_calls.synchronize do
@id += 1
@pending_calls << [@id, procedure, args, need_retval]
end
- if need_retval
- loop do
- @protect_pending_retvals.synchronize do
- ary = @pending_retvals.find { |id, _retval| id == @id }
- if ary
- @pending_retvals.delete(ary)
- return ary[1]
- end
+ return unless need_retval
+
+ loop do
+ @protect_pending_retvals.synchronize do
+ ary = @pending_retvals.find { |id, _retval| id == @id }
+ if ary
+ @pending_retvals.delete(ary)
+ return ary[1]
end
end
end
end
end