with shared memory

This commit is contained in:
2026-03-23 23:33:13 +01:00
parent 02fbc54e07
commit eb4e15c66b
4 changed files with 569 additions and 0 deletions

60
rktwebview_qt/shm.h Normal file
View 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