UV/Loop.pm untested

filter: Statementstmt n/a Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a SCAR -
1 package SPVM::UV::Loop;
2  
3  
4  
5 1;
6  
7 =encoding utf8
8  
9 =head1 Name
10  
11 L<SPVM::UV::Loop|SPVM::UV::Loop> - libuv Event Loop
12  
13 =head1 Description
14  
15 C<UV::Loop> class in L<SPVM> represents an event loop in L<libuv|https://libuv.org/>.
16  
17 =head1 Usage
18  
19 use UV::Loop;
20 use UV::Constant as UV_C;
21
22 my $uv_loop = UV::Loop->new;
23
24 $uv_loop->run(UV_C->UV_RUN_DEFAULT);
25  
26 =head1 Fields
27  
28 =head2 uv_handles_h
29  
30 C<has uv_handles_h : Hash of L<UV::Handle|SPVM::UV::Handle>;>
31  
32 A hash that holds active handles associated with this event loop.
33  
34 =head2 uv_requests_h
35  
36 C<has uv_requests_h : Hash of L<UV::Request|SPVM::UV::Request>;>
37  
38 A hash that holds active requests associated with this event loop.
39  
40 =head1 Class Methods
41  
42 =head2 new
43  
44 C<static method new : L<UV::Loop|SPVM::UV::Loop> ();>
45  
46 Creates a new L<libuv loop|https://docs.libuv.org/en/v1.x/loop.html#c.uv_loop_init>.
47  
48 Exceptions:
49  
50 If C<uv_loop_init> fails, an exception is thrown.=head1 Instance Methods
51  
52 =head2 run
53  
54 C<method run : int ($uv_run_mode : int);>
55  
56 Runs the event loop with the specified mode, and returns the return value of L<uv_run|https://docs.libuv.org/en/v1.x/loop.html#c.uv_run>.
57  
58 See L<UV::Constant|SPVM::UV::Constant> for constants such as C<UV_RUN_XXX> specified at $uv_run_mode.
59  
60 =head2 idle_init
61  
62 C<method idle_init : void ($uv_idle : L<UV::Handle::Idle|SPVM::UV::Handle::Idle>);>
63  
64 Initializes an idle handle $uv_idle associated with the event loop. See L<uv_idle_init|https://docs.libuv.org/en/v1.x/idle.html#c.uv_idle_init>.
65  
66 Exceptions:
67  
68 $uv_idle must be defined. Otherwise an exception is thrown.
69  
70 =head2 timer_init
71  
72 C<method timer_init : void ($uv_timer : L<UV::Handle::Timer|SPVM::UV::Handle::Timer>);>
73  
74 Initializes a timer handle $uv_timer associated with the event loop. See L<uv_timer_init|https://docs.libuv.org/en/v1.x/timer.html#c.uv_timer_init>.
75  
76 Exceptions:
77  
78 $uv_timer must be defined. Otherwise an exception is thrown.
79  
80 If C<uv_timer_init> fails, an exception is thrown.
81  
82 =head2 poll_init
83  
84 C<method poll_init : void ($uv_poll : L<UV::Handle::Poll|SPVM::UV::Handle::Poll>, $fd : int);>
85  
86 Initializes a poll handle $uv_poll for the given file descriptor $fd associated with the event loop. See L<uv_poll_init|https://docs.libuv.org/en/v1.x/poll.html#c.uv_poll_init>.
87  
88 Exceptions:
89  
90 $uv_poll must be defined. Otherwise an exception is thrown.
91  
92 If C<uv_poll_init> fails, an exception is thrown.
93  
94 Exceptions:
95  
96 $uv_async must be defined. Otherwise an exception is thrown.
97  
98 $cb must be defined. Otherwise an exception is thrown.
99  
100 If C<uv_async_init> fails, an exception is thrown.
101  
102 =head2 async_init
103  
104 C<method async_init : void ($uv_async : L<UV::Handle::Async|SPVM::UV::Handle::Async>, $cb : L<UV::Callback::Async|SPVM::UV::Callback::Async>);>
105  
106 Initializes an async handle $uv_async associated with the event loop with a callback $cb. L<UV::Handle::Async#async_cb|SPVM::UV::Handle::Async/"async_cb"> field is set to $cb. See L<uv_async_init|https://docs.libuv.org/en/v1.x/async.html#c.uv_async_init>.
107  
108 Exceptions:
109  
110 $uv_pipe must be defined. Otherwise an exception is thrown.
111  
112 If C<uv_pipe_init> fails, an exception is thrown.
113  
114 =head2 pipe_init
115  
116 C<method pipe_init : void ($uv_pipe : L<UV::Handle::Pipe|SPVM::UV::Handle::Pipe>, $ipc : int);>
117  
118 Initializes a pipe handle $uv_pipe associated with the event loop with $ipc. See L<uv_pipe_init|https://docs.libuv.org/en/v1.x/pipe.html#c.uv_pipe_init>.
119  
120 =head2 spawn
121  
122 C<method spawn : int ($uv_process : L<UV::Handle::Process|SPVM::UV::Handle::Process>, $options : L<UV::ProcessOptions|SPVM::UV::ProcessOptions>);>
123  
124 Spawns a process with the specified options associated with the event loop, and returns the return value of L<uv_spawn|https://docs.libuv.org/en/v1.x/process.html#c.uv_spawn>.
125  
126 The callback in L<UV::Handle::Process|SPVM::UV::Handle::Process> C<on_exit_cb> field is set to the callback specified in C<$options>. After the exit callback is invoked, the callback in C<on_exit_cb> field is set to C<undef>.
127  
128 Exceptions:
129  
130 $uv_process must be defined. Otherwise an exception is thrown.
131  
132 $options must be defined. Otherwise an exception is thrown.
133  
134 If C<uv_spawn> fails, an exception is thrown.
135  
136 =head2 signal_init
137  
138 C<method signal_init : void ($uv_signal : L<UV::Handle::Signal|SPVM::UV::Handle::Signal>);>
139  
140 Initializes a signal handle $uv_signal associated with the event loop. See L<uv_signal_init|https://docs.libuv.org/en/v1.x/signals.html#c.uv_signal_init>.
141  
142 Exceptions:
143  
144 $uv_signal must be defined. Otherwise an exception is thrown.
145  
146 If C<uv_signal_init> fails, an exception is thrown.
147  
148 =head2 fs_event_init
149  
150 C<method fs_event_init : void ($uv_fs_event : L<UV::Handle::FsEvent|SPVM::UV::Handle::FsEvent>);>
151  
152 Initializes a file system event handle $uv_fs_event associated with the event loop. See L<uv_fs_event_init|https://docs.libuv.org/en/v1.x/fs_event.html#c.uv_fs_event_init>.
153  
154 Exceptions:
155  
156 $uv_fs_event must be defined. Otherwise an exception is thrown.
157  
158 If C<uv_fs_event_init> fails, an exception is thrown.
159  
160 =head2 alive
161  
162 C<method alive : int ();>
163  
164 Returns a non-zero value if there are active handles or requests in the event loop, or 0 otherwise. See L<uv_loop_alive|https://docs.libuv.org/en/v1.x/loop.html#c.uv_loop_alive>.
165  
166 =head2 tcp_init
167  
168 C<method tcp_init : void ($uv_tcp : L<UV::Handle::TCP|SPVM::UV::Handle::TCP>);>
169  
170 Initializes a TCP handle $uv_tcp associated with the event loop. See L<uv_tcp_init|https://docs.libuv.org/en/v1.x/tcp.html#c.uv_tcp_init>.
171  
172 Exceptions:
173  
174 $uv_tcp must be defined. Otherwise an exception is thrown.
175  
176 If C<uv_tcp_init> fails, an exception is thrown.
177  
178 =head2 DESTROY
179  
180 C<method DESTROY : void ();>
181  
182 Destroys the event loop and releases its resources. See L<uv_loop_close|https://docs.libuv.org/en/v1.x/loop.html#c.uv_loop_close>.
183  
184 Exceptions:
185  
186 If C<uv_loop_close> fails, an exception is thrown.