-
Notifications
You must be signed in to change notification settings - Fork 3
/
loop-wrapper.dylan
85 lines (69 loc) · 2.04 KB
/
loop-wrapper.dylan
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
module: uv
author: Bruce Mitchener <[email protected]>
copyright: MIT
define C-subtype <uv-loop> (<C-void*>) end;
define inline C-function uv-default-loop
result loop :: <uv-loop>;
c-name: "uv_default_loop";
end;
define constant <uv-run-mode> = <integer>;
define constant $UV-RUN-DEFAULT = 0;
define constant $UV-RUN-ONCE = 1;
define constant $UV-RUN-NOWAIT = 2;
define inline C-function %uv-run
parameter loop :: <uv-loop>;
parameter run-mode :: <C-signed-int>;
c-name: "uv_run";
end;
define inline function uv-run
(#key loop :: <uv-loop> = uv-default-loop(),
run-mode :: <uv-run-mode> = $UV-RUN-DEFAULT)
=> ()
%uv-run(loop, run-mode);
end;
define inline C-function %uv-stop
parameter loop :: <uv-loop>;
c-name: "uv_stop";
end;
define inline function uv-stop (#key loop :: <uv-loop> = uv-default-loop()) => ()
%uv-stop(loop);
end;
define inline C-function uv-ref
parameter loop :: <uv-loop>;
c-name: "uv_ref";
end;
define inline C-function uv-unref
parameter loop :: <uv-loop>;
c-name: "uv_unref";
end;
define inline C-function %uv-update-time
parameter loop :: <uv-loop>;
c-name: "uv_update_time";
end;
define inline function uv-update-time (#key loop :: <uv-loop> = uv-default-loop()) => ()
%uv-update-time(loop);
end;
define inline C-function %uv-now
parameter loop :: <uv-loop>;
output parameter low :: <C-unsigned-int*>;
output parameter high :: <C-unsigned-int*>;
c-name: "uv_dylan_now";
end;
define inline function uv-now (#key loop :: <uv-loop> = uv-default-loop()) => (_ :: <double-integer>)
let (low, high) = %uv-now(loop);
make(<double-integer>, low: as(<machine-word>, low), high: as(<machine-word>, high))
end;
define inline C-function %uv-dylan-loop-new
result loop :: <uv-loop>;
c-name: "uv_dylan_loop_new";
end;
define sealed domain make (singleton(<uv-loop>));
define sealed method make (class == <uv-loop>, #rest args, #key address, #all-keys)
=> (loop :: <uv-loop>)
if (address)
next-method();
else
let loop = %uv-dylan-loop-new();
loop
end;
end method make;