-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cross-platform code for semaphore
- Loading branch information
ben
committed
Aug 11, 2024
1 parent
e648ca6
commit 161b5b9
Showing
6 changed files
with
272 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,28 @@ | ||
#pragma once | ||
#include <semaphore.h> | ||
#include <string> | ||
#include "Message.hpp" | ||
|
||
class SharedMemoryReceiver | ||
{ | ||
public: | ||
SharedMemoryReceiver(const char *shMemName); | ||
void init(); | ||
~SharedMemoryReceiver(); | ||
|
||
#ifdef WIN32 | ||
void initWindowsSharedMemory(); | ||
void finishWindows(); | ||
#else | ||
void initUnixSharedMemory(); | ||
void finish(); | ||
#endif | ||
Message *receiveMessage(); | ||
|
||
private: | ||
#ifndef _WIN32 | ||
int m_shm_fd; | ||
#else | ||
HANDLE m_shm_fd; | ||
#endif | ||
void *m_ptr; | ||
sem_t *m_sem; | ||
sem_t *m_rec_sem; | ||
std::string m_name; | ||
}; |
Oops, something went wrong.