2019-12-03 03:39:53 +01:00
|
|
|
#ifndef VOXELMAN_QUEUE_H
|
|
|
|
#define VOXELMAN_QUEUE_H
|
|
|
|
|
|
|
|
#include "core/reference.h"
|
|
|
|
|
|
|
|
#include "core/os/copymem.h"
|
|
|
|
#include "core/os/memory.h"
|
|
|
|
#include "core/os/rw_lock.h"
|
|
|
|
#include "core/variant.h"
|
|
|
|
|
2020-01-09 04:29:05 +01:00
|
|
|
template <class T>
|
2019-12-03 03:39:53 +01:00
|
|
|
class VMQueue {
|
|
|
|
|
|
|
|
public:
|
2020-01-09 04:29:05 +01:00
|
|
|
void enqueue(T obj);
|
|
|
|
T dequeue();
|
|
|
|
T peek();
|
2019-12-03 03:39:53 +01:00
|
|
|
|
2020-01-09 04:29:05 +01:00
|
|
|
void resize(int new_size);
|
2019-12-03 03:39:53 +01:00
|
|
|
|
2020-01-09 04:29:05 +01:00
|
|
|
VMQueue(int initial_size);
|
|
|
|
VMQueue();
|
|
|
|
~VMQueue();
|
2019-12-03 03:39:53 +01:00
|
|
|
|
|
|
|
protected:
|
2020-01-09 04:29:05 +01:00
|
|
|
void _resize(int new_size);
|
2019-12-03 03:39:53 +01:00
|
|
|
|
|
|
|
private:
|
2020-01-09 04:29:05 +01:00
|
|
|
RWLock *_lock;
|
2019-12-03 03:39:53 +01:00
|
|
|
|
2020-01-09 04:29:05 +01:00
|
|
|
int _head;
|
|
|
|
int _count;
|
|
|
|
int _size;
|
|
|
|
T *_items;
|
2019-12-03 03:39:53 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class VoxelmanQueue : public Reference {
|
2020-01-09 04:29:05 +01:00
|
|
|
GDCLASS(VoxelmanQueue, Reference);
|
2019-12-03 03:39:53 +01:00
|
|
|
|
|
|
|
public:
|
2020-01-09 04:29:05 +01:00
|
|
|
void enqueue(Variant obj);
|
|
|
|
Variant dequeue();
|
|
|
|
Variant peek();
|
2019-12-03 03:39:53 +01:00
|
|
|
|
2020-01-09 04:29:05 +01:00
|
|
|
void resize(int new_size);
|
2019-12-03 03:39:53 +01:00
|
|
|
|
2020-01-09 04:29:05 +01:00
|
|
|
VoxelmanQueue();
|
|
|
|
~VoxelmanQueue();
|
2019-12-03 03:39:53 +01:00
|
|
|
|
|
|
|
protected:
|
2020-01-09 04:29:05 +01:00
|
|
|
static void _bind_methods();
|
2019-12-03 03:39:53 +01:00
|
|
|
|
|
|
|
private:
|
2020-01-09 04:29:05 +01:00
|
|
|
VMQueue<Variant> _queue;
|
2019-12-03 03:39:53 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|