Skip to content
Snippets Groups Projects
Commit 3ad3a4df authored by Martin Stjernholm's avatar Martin Stjernholm
Browse files

Added Thread.Queue.peek_array.

parent ed3c0e9f
No related branches found
No related tags found
No related merge requests found
......@@ -384,6 +384,19 @@ optional class Queue {
return ret;
}
//! Returns a snapshot of all the values in the queue, in the order
//! they were written. The values are still left in the queue, so if
//! other threads are reading from it, the returned value should be
//! considered stale already on return.
array peek_array()
{
if (w_ptr == r_ptr) return ({});
MutexKey key = lock::lock();
array ret = buffer[r_ptr..w_ptr - 1];
key = 0;
return ret;
}
//! This function puts a @[value] last in the queue. If the queue is
//! too small to hold the @[value] it will be expanded to make room.
//! The number of items in the queue after the write is returned.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment