X threading handling

This commit is contained in:
Cedric Roux
2016-04-29 18:29:04 +02:00
parent 3bba991e77
commit 88bef83d8b
4 changed files with 26 additions and 0 deletions
+2
View File
@@ -9,11 +9,13 @@ void glock(gui *_gui)
{
struct gui *g = _gui;
if (pthread_mutex_lock(g->lock)) ERR("mutex error\n");
xlock(g->x);
}
void gunlock(gui *_gui)
{
struct gui *g = _gui;
xunlock(g->x);
if (pthread_mutex_unlock(g->lock)) ERR("mutex error\n");
}
+2
View File
@@ -12,6 +12,8 @@ gui *gui_init(void)
{
struct gui *ret;
x_init_threading();
ret = calloc(1, sizeof(struct gui));
if (ret == NULL) OOM;
+17
View File
@@ -6,6 +6,23 @@
#include <stdlib.h>
#include <string.h>
void x_init_threading(void)
{
if (XInitThreads() == False) abort();
}
void xlock(x_connection *_x)
{
struct x_connection *x = _x;
XLockDisplay(x->d);
}
void xunlock(x_connection *_x)
{
struct x_connection *x = _x;
XUnlockDisplay(x->d);
}
int x_connection_fd(x_connection *_x)
{
struct x_connection *x = _x;
+5
View File
@@ -6,6 +6,11 @@
typedef void x_connection;
typedef void x_window;
void x_init_threading(void);
void xlock(x_connection *x);
void xunlock(x_connection *x);
x_connection *x_open(void);
x_window *x_create_window(x_connection *x, int width, int height,