with shared memory
This commit is contained in:
60
rktwebview_qt/shm.h
Normal file
60
rktwebview_qt/shm.h
Normal file
@@ -0,0 +1,60 @@
|
||||
#ifndef SHM_H
|
||||
#define SHM_H
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
class ShmApi;
|
||||
typedef int ShmPlace;
|
||||
typedef int ShmSlot;
|
||||
|
||||
#define SHM_MAX_SLOTS 100
|
||||
#define SHM_NULL -1
|
||||
|
||||
class ShmSem {
|
||||
private:
|
||||
void *_sem;
|
||||
char *_name;
|
||||
bool _owner;
|
||||
|
||||
public:
|
||||
void post();
|
||||
void wait();
|
||||
bool trywait();
|
||||
|
||||
public:
|
||||
ShmSem(const char *n, bool owner);
|
||||
~ShmSem();
|
||||
};
|
||||
|
||||
class Shm
|
||||
{
|
||||
private:
|
||||
ShmApi *_shm_api;
|
||||
|
||||
public:
|
||||
ShmPlace alloc(size_t mem);
|
||||
void free(ShmPlace place);
|
||||
void lock();
|
||||
void unlock();
|
||||
|
||||
public:
|
||||
ShmPlace slot(ShmSlot s);
|
||||
void setSlot(ShmSlot s, ShmPlace pl);
|
||||
|
||||
public:
|
||||
ShmSem *sem(const char *name, bool owner);
|
||||
|
||||
public:
|
||||
const char *name();
|
||||
|
||||
public:
|
||||
void *ref(int place);
|
||||
|
||||
public:
|
||||
Shm(const char *name, size_t bytes, bool owner);
|
||||
~Shm();
|
||||
};
|
||||
|
||||
template <class T> void ref(Shm *shm, int place, T **p);
|
||||
|
||||
#endif // SHM_H
|
||||
Reference in New Issue
Block a user