Skip to content

Commit c3efc2f

Browse files
committed
Buffer optimization
if nothing is scheduled execute the message right away do not pass it to another scheduling block, saves context switching
1 parent 1ba0da9 commit c3efc2f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/concurrent/actor/behaviour.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def on_envelope(envelope)
195195
def process_envelopes?
196196
unless @buffer.empty? || @receive_envelope_scheduled
197197
@receive_envelope_scheduled = true
198-
schedule_execution { receive_envelope }
198+
receive_envelope
199199
end
200200
end
201201

@@ -205,7 +205,7 @@ def receive_envelope
205205
pass envelope
206206
ensure
207207
@receive_envelope_scheduled = false
208-
process_envelopes?
208+
schedule_execution { process_envelopes? }
209209
end
210210

211211
def reject_messages

0 commit comments

Comments
 (0)