Concord - C Discord API library
A Discord API wrapper library written in C
io_poller.h
Go to the documentation of this file.
1#ifndef CONCORD_IO_POLLER_H
2#define CONCORD_IO_POLLER_H
3
4#include <stdbool.h>
5#include <curl/curl.h>
6
11 IO_POLLER_IN = 1 << 0,
12 IO_POLLER_OUT = 1 << 1,
13};
14
18typedef int io_poller_socket;
19
23struct io_poller;
24
28typedef void (*io_poller_cb)(struct io_poller *io,
29 enum io_poller_events events,
30 void *user_data);
31
32struct io_poller *io_poller_create(void);
33void io_poller_destroy(struct io_poller *io);
34
40void
41io_poller_wakeup(struct io_poller *io);
42
49int io_poller_poll(struct io_poller *io, int milliseconds);
50
56int io_poller_perform(struct io_poller *io);
57
67bool io_poller_socket_add(struct io_poller *io,
69 enum io_poller_events events,
70 io_poller_cb cb,
71 void *user_data);
72
79bool io_poller_socket_del(struct io_poller *io, io_poller_socket sock);
80
84typedef int (*io_poller_curl_cb)(struct io_poller *io,
85 CURLM *multi,
86 void *user_data);
87
96bool io_poller_curlm_add(struct io_poller *io,
97 CURLM *multi,
99 void *user_data);
100
107bool io_poller_curlm_del(struct io_poller *io, CURLM *multi);
108
116bool io_poller_curlm_enable_perform(struct io_poller *io, CURLM *multi);
117
118#endif // CONCORD_IO_POLLER_H
io_poller_events
The flags to poll for.
Definition: io_poller.h:10
@ IO_POLLER_IN
Definition: io_poller.h:11
@ IO_POLLER_OUT
Definition: io_poller.h:12
int io_poller_perform(struct io_poller *io)
performs any actions needed and clears events set by io_poller_poll
void io_poller_destroy(struct io_poller *io)
bool io_poller_socket_del(struct io_poller *io, io_poller_socket sock)
removes a socket or file descriptor from watch list
bool io_poller_socket_add(struct io_poller *io, io_poller_socket sock, enum io_poller_events events, io_poller_cb cb, void *user_data)
adds or modifies a socket or file descriptor to watch list
bool io_poller_curlm_enable_perform(struct io_poller *io, CURLM *multi)
this multi should be performed on next cycle causing poll to return immediately
void(* io_poller_cb)(struct io_poller *io, enum io_poller_events events, void *user_data)
callback for when an event is triggered by the socket
Definition: io_poller.h:28
int io_poller_poll(struct io_poller *io, int milliseconds)
wait for events to be triggered
struct io_poller * io_poller_create(void)
int(* io_poller_curl_cb)(struct io_poller *io, CURLM *multi, void *user_data)
callback for when curl multi should be performed on
Definition: io_poller.h:84
void io_poller_wakeup(struct io_poller *io)
wakeup the thread listening to this io_poller
int io_poller_socket
a socket or file descriptor
Definition: io_poller.h:18
bool io_poller_curlm_del(struct io_poller *io, CURLM *multi)
remove curl multi from watch list
bool io_poller_curlm_add(struct io_poller *io, CURLM *multi, io_poller_curl_cb cb, void *user_data)
add or modifies a curl multi to watch list