initial commit
This commit is contained in:
51
solanaceae/ipc1/tox_ipc_server.hpp
Normal file
51
solanaceae/ipc1/tox_ipc_server.hpp
Normal file
@@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
|
||||
//#include <solanaceae/core/tox_interface.hpp>
|
||||
|
||||
#include <ipc.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
// fwd
|
||||
struct ToxI;
|
||||
struct Tox_Events;
|
||||
|
||||
class ToxIPCServer {
|
||||
ipc_sharedmemory _mem_rpc;
|
||||
ipc_sharedsemaphore _sem_rpc_c;
|
||||
ipc_sharedsemaphore _sem_rpc_s;
|
||||
|
||||
ipc_sharedmemory _mem_events;
|
||||
ipc_sharedsemaphore _sem_events_lock;
|
||||
|
||||
ToxI& _t;
|
||||
std::mutex& _t_m;
|
||||
|
||||
std::atomic_bool _quit = false;
|
||||
|
||||
std::thread _thread;
|
||||
|
||||
std::vector<uint8_t> _tmp_events_buf;
|
||||
|
||||
void run(void);
|
||||
|
||||
public:
|
||||
ToxIPCServer(ToxI& t, std::mutex& t_m);
|
||||
~ToxIPCServer(void);
|
||||
|
||||
bool connect(void);
|
||||
|
||||
// starts a thread and serves
|
||||
void start(void);
|
||||
void stop(void);
|
||||
|
||||
// take events, serialize
|
||||
void updateEvents(const Tox_Events* events);
|
||||
|
||||
// this might sleep for longer, and events might get discarded
|
||||
void pub(void);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user