# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
import os
+from collections import deque
class SegmentInfoError(Exception):
"""An exception raised for general errors in the SegmentInfo class."""
# READY state. This maintains such pending events in the order
# they arrived. SegmentInfo doesn't have to know the details of
# the stored data; it only matters for the memmgr.
- self.__events = []
+ self.__events = deque()
def get_state(self):
"""Returns the state of SegmentInfo (UPDATING, SYNCHRONIZING,
def get_events(self):
"""Returns a list of pending events in the order they arrived."""
- return self.__events
+ return list(self.__events)
# Helper method used in complete_update(), sync_reader() and
# remove_reader().
if not self.__old_readers:
self.__state = new_state
if self.__events:
- e = self.__events[0]
- del self.__events[0]
- return e
+ return self.__events.popleft()
return None