Skip to content

Commit

Permalink
Merge pull request #841 from projectcalico/smc-use-deque
Browse files Browse the repository at this point in the history
Use a deque for the Actor's event queue.
  • Loading branch information
Peter White committed Oct 8, 2015
2 parents 6936e8e + af39cc3 commit 2b787d5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions calico/felix/actor.py
Expand Up @@ -133,7 +133,7 @@ class Actor(object):
"""Number of calls to self._maybe_yield before it yields"""

def __init__(self, qualifier=None):
self._event_queue = []
self._event_queue = collections.deque()

# Set to True when the main loop is actively processing the input
# queue or has been scheduled to do so. Set to False when the loop
Expand Down Expand Up @@ -244,7 +244,7 @@ def _step(self):
# back to True.
assert self._scheduled, ("Switched to %s from %s but _scheduled "
"set to False." % (self, caller))
msg = self._event_queue.pop(0)
msg = self._event_queue.popleft()

batch = [msg]
batches = []
Expand All @@ -255,7 +255,7 @@ def _step(self):
while self._event_queue:
# We're the only ones getting from the queue so this should
# never fail.
msg = self._event_queue.pop(0)
msg = self._event_queue.popleft()
if msg.needs_own_batch:
if batch:
batches.append(batch)
Expand Down

0 comments on commit 2b787d5

Please sign in to comment.