2011-12-23 22:58:50 +00:00
|
|
|
#ifndef _PAYSAGES_SYSTEM_H_
|
|
|
|
#define _PAYSAGES_SYSTEM_H_
|
|
|
|
|
2011-12-10 13:25:22 +00:00
|
|
|
#include <glib.h>
|
|
|
|
|
2011-12-23 22:58:50 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2011-12-10 13:25:22 +00:00
|
|
|
typedef GThread Thread;
|
|
|
|
typedef void*(*ThreadFunction)(void* data);
|
|
|
|
|
2012-01-07 16:53:23 +00:00
|
|
|
static inline void systemInit()
|
|
|
|
{
|
|
|
|
g_thread_init(NULL);
|
|
|
|
}
|
|
|
|
|
2011-12-10 13:25:22 +00:00
|
|
|
static inline Thread* threadCreate(ThreadFunction function, void* data)
|
|
|
|
{
|
|
|
|
GError* error;
|
|
|
|
return g_thread_create((GThreadFunc)function, data, 1, &error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void* threadJoin(Thread* thread)
|
|
|
|
{
|
|
|
|
return g_thread_join(thread);
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef GMutex Mutex;
|
|
|
|
|
|
|
|
static inline Mutex* mutexCreate()
|
|
|
|
{
|
|
|
|
return g_mutex_new();
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void mutexDestroy(Mutex* mutex)
|
|
|
|
{
|
|
|
|
g_mutex_free(mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void mutexAcquire(Mutex* mutex)
|
|
|
|
{
|
|
|
|
g_mutex_lock(mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void mutexRelease(Mutex* mutex)
|
|
|
|
{
|
|
|
|
g_mutex_unlock(mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void timeSleepMs(unsigned long ms)
|
|
|
|
{
|
|
|
|
g_usleep(ms * 1000);
|
|
|
|
}
|
|
|
|
|
2011-12-23 22:58:50 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|