24 #ifndef TESSERACT_VIEWER_SVUTIL_H__ 25 #define TESSERACT_VIEWER_SVUTIL_H__ 31 #if defined(_MSC_VER) && _MSC_VER < 1900 32 #define snprintf _snprintf 34 #if (_MSC_VER <= 1400) 35 #define vsnprintf _vsnprintf 37 #pragma warning(disable:4786) 44 #include <semaphore.h> 50 #define MAX(a, b) ((a > b) ? a : b) 54 #define MIN(a, b) ((a < b) ? a : b) 61 static void StartThread(
void *(*func)(
void*),
void* arg);
65 static void StartProcess(
const char* executable,
const char* args);
81 #elif defined(__APPLE__) 102 pthread_mutex_t mutex_;
124 SVNetwork(
const char* hostname,
int port);
130 void Send(
const char* msg);
148 char* msg_buffer_in_;
151 std::string msg_buffer_out_;
158 #endif // TESSERACT_VIEWER_SVUTIL_H__ SVSemaphore()
Sets up a semaphore.
static void ExitThread()
Signals a thread to exit.
SVMutex()
Sets up a new mutex.
void Wait()
Wait on a semaphore.
static void StartProcess(const char *executable, const char *args)
Starts a new process.
SVAutoLock(SVMutex *mutex)
The SVSync class provides functionality for Thread & Process Creation.
void Send(const char *msg)
Put a message in the messagebuffer to the server and try to send it.
void Lock()
Locks on a mutex.
SVNetwork(const char *hostname, int port)
Set up a connection to hostname on port.
void Flush()
Flush the buffer.
void Unlock()
Unlocks on a mutex.
void Close()
Close the connection to the server.
void Signal()
Signal a semaphore.
static void StartThread(void *(*func)(void *), void *arg)
Create new thread.