File: uloop.c

package info (click to toggle)
libwebsockets 4.3.5-2
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 31,288 kB
  • sloc: ansic: 194,407; javascript: 1,550; sh: 1,387; cpp: 505; java: 461; perl: 405; xml: 118; makefile: 76; awk: 5
file content (59 lines) | stat: -rw-r--r-- 1,076 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
 * lws-minimal-http-server-eventlib-foreign
 *
 * Written in 2010-2020 by Andy Green <andy@warmcat.com>
 *
 * This file is made available under the Creative Commons CC0 1.0
 * Universal Public Domain Dedication.
 *
 * The uloop specific code
 */

#include <libwebsockets.h>

#include <libubox/uloop.h>

#include <string.h>
#include <signal.h>

#include "private.h"

static struct uloop_timeout timer_outer_uloop;

static void
timer_cb_uloop(struct uloop_timeout *ti)
{
	foreign_timer_service(NULL);
	uloop_timeout_set(&timer_outer_uloop, 1090);
}

static void
foreign_event_loop_init_and_run_uloop(void)
{
	uloop_init();

	timer_outer_uloop.cb = timer_cb_uloop;
	uloop_timeout_add(&timer_outer_uloop);

	uloop_timeout_set(&timer_outer_uloop, 1090);

	uloop_run();
}

static void
foreign_event_loop_stop_uloop(void)
{
	uloop_end();
}

static void
foreign_event_loop_cleanup_uloop(void)
{
	uloop_timeout_cancel(&timer_outer_uloop);
}

const struct ops ops_uloop = {
	foreign_event_loop_init_and_run_uloop,
	foreign_event_loop_stop_uloop,
	foreign_event_loop_cleanup_uloop
};