4#ifndef TRAM_SDK_TEMPLATES_QUEUE_H
5#define TRAM_SDK_TEMPLATES_QUEUE_H
19 T* allocated_memory = (T*)::
operator new (
count *
sizeof(T));
21 first = allocated_memory;
22 last = allocated_memory;
31 template <
typename... Args>
32 void push (Args&&... args) {
36 std::cout <<
"Queue " <<
name <<
" out of space!" << std::endl;
41 new (
last) T (std::forward<Args>(args)...);
bool try_pop(T &value)
Thread safe.
Definition: queue.h:82
void unlock()
Definition: queue.h:100
void lock()
Definition: queue.h:99
T * memory_start
Definition: queue.h:108
void push(Args &&... args)
Thread safe.
Definition: queue.h:32
T & front()
Definition: queue.h:66
Queue(const Queue &)=delete
std::atomic< bool > spinlock
Definition: queue.h:111
void pop()
Definition: queue.h:54
T * last
Definition: queue.h:107
size_t count
Definition: queue.h:105
const char * name
Definition: queue.h:103
T * memory_end
Definition: queue.h:109
T & back()
Definition: queue.h:70
Queue(const char *name, size_t count)
Definition: queue.h:18
T * first
Definition: queue.h:106
size_t csize
Definition: queue.h:104
size_t size()
Definition: queue.h:97