Commit Graph

9 Commits

Author SHA1 Message Date
Avi Kivity
7f8d88371a Add LICENSE, NOTICE, and copyright headers to all source files.
The two files imported from the OSv project retain their original licenses.
2015-02-19 16:52:34 +02:00
Gleb Natapov
bb072fc5c9 core: add iterator for circular_buffer container 2015-01-28 13:49:09 +02:00
Gleb Natapov
f58926acd1 core: fix circular_buffer::emplace_(back|front) to take universal references 2015-01-12 17:30:45 +02:00
Avi Kivity
535b447343 circular_buffer: get rid of {pre|post}_push_{front|back}
As Nadav suggests, with the simplified circular_buffer implementation they
no longer provide any value and only obfuscate the code.
2014-12-14 10:00:43 +02:00
Avi Kivity
9de1b10724 circular_buffer: add unsafe array access method
By allowing access-past-the-end, we can prefetch ahead of the queue without
checking the current queue size.
2014-12-11 22:20:50 +02:00
Avi Kivity
ec0fb398fb circular_buffer: optimize by using masking instead of tests
Since we control the capacity, we can force it to be a power of two,
and use masking instead of tests to handle wraparound.

A side benefit is that we don't have to allocate an extra element.
2014-12-11 22:14:02 +02:00
Avi Kivity
aaf9884064 circular_buffer: fix pop_front(), pop_back()
These methods should destroy the objects they are popping.

We probably haven't seen any leaks since we usually move() the item
before popping it.
2014-12-11 21:55:09 +02:00
Avi Kivity
746dfae355 circular_buffer: add array dereference operator
Useful for prefetching.
2014-12-11 21:32:56 +02:00
Avi Kivity
dacf81745e core: add circular_buffer
Since we have lots of queues, we need an efficient queue structure,
esp. for moveable types.  libstdc++'s std::deque is quite hairy,
and boost's circular_buffer_space_optimized uses assignments instead of
constructors, which are both slower and less available than constructors.

This patch implements a growable circular buffer for these needs.
2014-10-02 14:32:32 +03:00