aboutsummaryrefslogtreecommitdiffstats
path: root/src/wayland-client.h
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2012-10-04 16:54:22 -0400
committerKristian Høgsberg <krh@bitplanet.net>2012-10-10 20:59:00 -0400
commit53d24713a31d59d9534c1c1a84a7ad46f44ee95f (patch)
tree0e550fa29c2e5b9ccc757b307dfed026143c3a24 /src/wayland-client.h
parentEnsure cursor_data.c is included in distribution tarballs (diff)
downloadwayland-53d24713a31d59d9534c1c1a84a7ad46f44ee95f.tar
wayland-53d24713a31d59d9534c1c1a84a7ad46f44ee95f.tar.gz
wayland-53d24713a31d59d9534c1c1a84a7ad46f44ee95f.tar.bz2
wayland-53d24713a31d59d9534c1c1a84a7ad46f44ee95f.tar.lz
wayland-53d24713a31d59d9534c1c1a84a7ad46f44ee95f.tar.xz
wayland-53d24713a31d59d9534c1c1a84a7ad46f44ee95f.tar.zst
wayland-53d24713a31d59d9534c1c1a84a7ad46f44ee95f.zip
Change filedescriptor API to be thread safe
The update callback for the file descriptors was always a bit awkward and un-intuitive. The idea was that whenever the protocol code needed to write data to the fd it would call the 'update' function. This function would adjust the mainloop so that it polls for POLLOUT on the fd so we can eventually flush the data to the socket. The problem is that in multi-threaded applications, any thread can issue a request, which writes data to the output buffer and thus triggers the update callback. Thus, we'll be calling out with the display mutex held and may call from any thread. The solution is to eliminate the udpate callback and just require that the application or server flushes all connection buffers before blocking. This turns out to be a simpler API, although we now require clients to deal with EAGAIN and non-blocking writes. It also saves a few syscalls, since the socket will be writable most of the time and most writes will complete, so we avoid changing epoll to poll for POLLOUT, then write and then change it back for each write.
Diffstat (limited to 'src/wayland-client.h')
-rw-r--r--src/wayland-client.h10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/wayland-client.h b/src/wayland-client.h
index 5cec28b..5fcb86d 100644
--- a/src/wayland-client.h
+++ b/src/wayland-client.h
@@ -66,19 +66,15 @@ struct wl_callback *wl_display_sync(struct wl_display *display);
#include "wayland-client-protocol.h"
-#define WL_DISPLAY_READABLE 0x01
-#define WL_DISPLAY_WRITABLE 0x02
-
typedef int (*wl_display_update_func_t)(uint32_t mask, void *data);
typedef void (*wl_callback_func_t)(void *data, uint32_t time);
struct wl_display *wl_display_connect(const char *name);
struct wl_display *wl_display_connect_to_fd(int fd);
void wl_display_disconnect(struct wl_display *display);
-int wl_display_get_fd(struct wl_display *display,
- wl_display_update_func_t update, void *data);
-void wl_display_iterate(struct wl_display *display, uint32_t mask);
-void wl_display_flush(struct wl_display *display);
+int wl_display_get_fd(struct wl_display *display);
+int wl_display_dispatch(struct wl_display *display);
+int wl_display_flush(struct wl_display *display);
void wl_display_roundtrip(struct wl_display *display);
struct wl_global_listener;