Exemple #1
0
void async_wakeup(async_t *const thread) {
	assert(thread != async_main);
	async_t *const original = async_main;
	async_main = async_active();
	async_switch(thread);
	async_main = original;
}
Exemple #2
0
static void trampoline_fn(void) {
	for(;;) {
		void (*const func)(void *) = arg_func;
		void *const arg = arg_arg;
		func(arg);
		async_switch(async_main);
	}
}
static void read_cb(uv_stream_t *const stream, ssize_t const nread, uv_buf_t const *const buf) {
	async_state *const state = stream->data;
	if(nread <= 0) {
		free(buf->base); // buf->base = NULL;
		state->buf->base = NULL;
		state->buf->len = 0;
		state->status = nread ? nread : UV_EAGAIN;
	} else {
		state->buf->base = buf->base; // buf->base = NULL;
		state->buf->len = nread;
		state->status = 0;
	}
	async_switch(state->thread);
}
Exemple #4
0
static void fs_cb(uv_fs_t *const req) {
	async_switch(req->data);
}
static void connect_cb(uv_connect_t *const req, int const status) {
	async_state *const state = req->data;
	state->status = status;
	async_switch(state->thread);
}
static void poll_cb(uv_poll_t *const handle, int const status, int const events) {
	struct poll_state *const state = handle->data;
	state->status = status;
	state->events = events;
	async_switch(state->thread);
}
Exemple #7
0
void async_yield(void) {
	async_switch(async_main);
}
Exemple #8
0
static void timer_cb(uv_timer_t *const timer) {
	async_switch(timer->data);
}
Exemple #9
0
static void close_cb(uv_handle_t *const handle) {
	async_switch(handle->data);
}
Exemple #10
0
static void getnameinfo_cb(uv_getnameinfo_t *const req, int const status, char const *const hostname, char const *const service) {
	async_switch(req->data);
}
Exemple #11
0
static void getaddrinfo_cb(uv_getaddrinfo_t *const req, int const status, struct addrinfo *const res) {
	getaddrinfo_state *const state = req->data;
	state->status = status;
	state->res = res;
	async_switch(state->thread);
}