1///|
2type Thread
3
4///|
5extern "c" fn uv_thread_make() -> type Thread
Thread = "moonbit_uv_thread_make"
6
7///|
8extern "c" fn uv_thread_create(thread : type Thread
Thread, callback : () -> Unit
Unit) -> Int
Int = "moonbit_uv_thread_create"
9
10///|
11pub fn type Thread
Thread::(callback : () -> Unit) -> Thread!Errno
new(() -> Unit
callback : () -> Unit
Unit) -> type Thread
Thread!type! Errno Status
Errno {
12 let Thread
thread = () -> Thread
uv_thread_make()
13 let Int
status = (thread : Thread, callback : () -> Unit) -> Int
uv_thread_create(Thread
thread, () -> Unit
callback)
14 if Int
status (x : Int, y : Int) -> Bool
!= 0 {
15 raise type! Errno Status
Errno::(errno : Int) -> Errno
of_int(Int
status)
16 }
17 return Thread
thread
18}
19
20///|
21extern "c" fn uv_thread_join(thread : type Thread
Thread) -> Int
Int = "moonbit_uv_thread_join"
22
23///|
24extern "c" fn uv_thread_self(thread : type Thread
Thread) -> Unit
Unit = "moonbit_uv_thread_self"
25
26///|
27extern "c" fn uv_thread_equal(thread : type Thread
Thread, other : type Thread
Thread) -> Int
Int = "moonbit_uv_thread_equal"
28
29///|
30extern "c" fn uv_thread_copy(thread : type Thread
Thread, other : type Thread
Thread) -> Unit
Unit = "moonbit_uv_thread_copy"
31
32///|
33pub fn type Thread
Thread::(self : Thread) -> Unit!Errno
join(Thread
self : type Thread
Thread) -> Unit
Unit!type! Errno Status
Errno {
34 let Int
status = (thread : Thread) -> Int
uv_thread_join(Thread
self)
35 if Int
status (x : Int, y : Int) -> Bool
!= 0 {
36 raise type! Errno Status
Errno::(errno : Int) -> Errno
of_int(Int
status)
37 }
38}
39
40///|
41pub fn type Thread
Thread::() -> Thread
current() -> type Thread
Thread {
42 let Thread
thread = () -> Thread
uv_thread_make()
43 (thread : Thread) -> Unit
uv_thread_self(Thread
thread)
44 return Thread
thread
45}
46
47///|
48pub fn type Thread
Thread::(self : Thread, other : Thread) -> Bool
equal(Thread
self : type Thread
Thread, Thread
other : type Thread
Thread) -> Bool
Bool {
49 return (thread : Thread, other : Thread) -> Int
uv_thread_equal(Thread
self, Thread
other) (x : Int, y : Int) -> Bool
!= 0
50}
51
52///|
53pub impl trait Copy {
copy(Self) -> Self
}
Copy for type Thread
Thread with (self : Thread) -> Thread
copy(Thread
self : type Thread
Thread) -> type Thread
Thread {
54 let Thread
other = () -> Thread
uv_thread_make()
55 (thread : Thread, other : Thread) -> Unit
uv_thread_copy(Thread
self, Thread
other)
56 return Thread
other
57}
58