with shared memory
This commit is contained in:
51
rktwebview_qt/shmqueue.h
Normal file
51
rktwebview_qt/shmqueue.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef SHMQUEUE_H
|
||||
#define SHMQUEUE_H
|
||||
|
||||
#include "shm.h"
|
||||
#include <QString>
|
||||
|
||||
#define COMMAND_SLOT 1
|
||||
#define EVENT_SLOT 2
|
||||
|
||||
typedef struct __ShmQueueItem__
|
||||
{
|
||||
int cmd;
|
||||
ShmPlace data_place;
|
||||
ShmPlace next;
|
||||
ShmPlace prev;
|
||||
} ShmQueueItem;
|
||||
|
||||
typedef struct __ShmQueue_
|
||||
{
|
||||
ShmPlace first;
|
||||
ShmPlace last;
|
||||
int count;
|
||||
} ShmQueueStart;
|
||||
|
||||
|
||||
class ShmQueue
|
||||
{
|
||||
private:
|
||||
Shm *_shm;
|
||||
|
||||
private:
|
||||
ShmQueueStart *_queue;
|
||||
ShmSem *_queue_sem;
|
||||
bool _owner;
|
||||
|
||||
private:
|
||||
void cleanup();
|
||||
|
||||
public:
|
||||
int depth();
|
||||
|
||||
public:
|
||||
bool dequeue(int &cmd, QString &json_data, bool wait = false);
|
||||
void enqueue(int cmd, const QString &json_data);
|
||||
|
||||
public:
|
||||
ShmQueue(Shm *shm, ShmSlot slot, bool owner);
|
||||
~ShmQueue();
|
||||
};
|
||||
|
||||
#endif // SHMQUEUE_H
|
||||
Reference in New Issue
Block a user