#ifndef SHM_H #define SHM_H #include 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 void ref(Shm *shm, int place, T **p); #endif // SHM_H