1///|
2type Idle Bytes
Bytes
3
4///|
5pub impl trait ToHandle {
to_handle(Self) -> Handle
of_handle(Handle) -> Self
close(Self, (Self) -> Unit) -> Unit
is_closing(Self) -> Bool
}
ToHandle for type Idle Bytes
Idle with to_handle(idle : type Idle Bytes
Idle) -> type Handle
Handle = "%identity"
6
7///|
8pub impl trait ToHandle {
to_handle(Self) -> Handle
of_handle(Handle) -> Self
close(Self, (Self) -> Unit) -> Unit
is_closing(Self) -> Bool
}
ToHandle for type Idle Bytes
Idle with of_handle(handle : type Handle
Handle) -> type Idle Bytes
Idle = "%identity"
9
10///|
11extern "c" fn uv_idle_make() -> type Idle Bytes
Idle = "moonbit_uv_idle_make"
12
13///|
14extern "c" fn uv_idle_init(loop_ : type Loop Bytes
Loop, idle : type Idle Bytes
Idle) -> Int
Int = "moonbit_uv_idle_init"
15
16///|
17pub fn type Idle Bytes
Idle::(self : Loop) -> Idle!Errno
new(Loop
self : type Loop Bytes
Loop) -> type Idle Bytes
Idle!type! Errno Status
Errno {
18 let Idle
idle = () -> Idle
uv_idle_make()
19 let Int
status = (loop_ : Loop, idle : Idle) -> Int
uv_idle_init(Loop
self, Idle
idle)
20 if Int
status (self_ : Int, other : Int) -> Bool
< 0 {
21 raise type! Errno Status
Errno::(errno : Int) -> Errno
of_int(Int
status)
22 }
23 return Idle
idle
24}
25
26///|
27extern "c" fn uv_idle_start(idle : type Idle Bytes
Idle, cb : (type Idle Bytes
Idle) -> Unit
Unit) -> Int
Int = "moonbit_uv_idle_start"
28
29///|
30extern "c" fn uv_idle_stop(idle : type Idle Bytes
Idle) -> Int
Int = "moonbit_uv_idle_stop"
31
32///|
33pub fn type Idle Bytes
Idle::(self : Idle, cb : (Idle) -> Unit) -> Unit!Errno
start(Idle
self : type Idle Bytes
Idle, (Idle) -> Unit
cb : (type Idle Bytes
Idle) -> Unit
Unit) -> Unit
Unit!type! Errno Status
Errno {
34 let Int
status = (idle : Idle, cb : (Idle) -> Unit) -> Int
uv_idle_start(Idle
self, fn(Idle
idle) { (Idle) -> Unit
cb(Idle
idle) })
35 if Int
status (self_ : Int, other : Int) -> Bool
< 0 {
36 raise type! Errno Status
Errno::(errno : Int) -> Errno
of_int(Int
status)
37 }
38}
39
40///|
41pub fn type Idle Bytes
Idle::(self : Idle) -> Unit!Errno
stop(Idle
self : type Idle Bytes
Idle) -> Unit
Unit!type! Errno Status
Errno {
42 let Int
status = (idle : Idle) -> Int
uv_idle_stop(Idle
self)
43 if Int
status (self_ : Int, other : Int) -> Bool
< 0 {
44 raise type! Errno Status
Errno::(errno : Int) -> Errno
of_int(Int
status)
45 }
46}
47