| 1 | package SPVM::UV::Handle; | ||
| 2 | |||
| 3 | |||
| 4 | |||
| 5 | 1; | ||
| 6 | |||
| 7 | =encoding utf8 | ||
| 8 | |||
| 9 | =head1 Name | ||
| 10 | |||
| 11 | SPVM::UV::Handle - Base Handle for libuv | ||
| 12 | |||
| 13 | =head1 Description | ||
| 14 | |||
| 15 | C<UV::Handle> in L<SPVM> represents the base handle for L<libuv|https://libuv.org/>, corresponding to the C<uv_handle_t> structure. | ||
| 16 | |||
| 17 | =head1 Usage | ||
| 18 | |||
| 19 | use UV::Handle; | ||
| 20 | |||
| 21 | =head1 Fields | ||
| 22 | |||
| 23 | =head2 close_cb | ||
| 24 | |||
| 25 | C<has close_cb : rw L<UV::Callback::Close|SPVM::UV::Callback::Close>;> | ||
| 26 | |||
| 27 | The callback called when the handle has been closed. | ||
| 28 | |||
| 29 | =head2 loop | ||
| 30 | |||
| 31 | C<has loop : ro L<UV::Loop|SPVM::UV::Loop>;> | ||
| 32 | |||
| 33 | The event loop associated with the handle. | ||
| 34 | |||
| 35 | =head1 Instance Methods | ||
| 36 | |||
| 37 | =head2 close_safe | ||
| 38 | |||
| 39 | C<method close_safe : void ($close_cb : L<UV::Callback::Close|SPVM::UV::Callback::Close> = undef);> | ||
| 40 | |||
| 41 | Request the handle to be closed safely. If the handle is not already closed, it checks whether it is closing using the L<uv_is_closing|https://docs.libuv.org/en/v1.x/handle.html#c.uv_is_closing> function, and if not, calls the L<uv_close|https://docs.libuv.org/en/v1.x/handle.html#c.uv_close> function. | ||
| 42 | |||
| 43 | The callback $close_cb is invoked when the handle has been closed. | ||
| 44 | |||
| 45 | The callback $close_cb is stored in L</"close_cb"> field. | ||
| 46 | |||
| 47 | Exceptions: | ||
| 48 | |||
| 49 | If uv_close fails, an exception is thrown. | ||
| 50 | |||
| 51 | =head2 get_type | ||
| 52 | |||
| 53 | C<method get_type : int ();> | ||
| 54 | |||
| 55 | Returns the handle type. | ||
| 56 | |||
| 57 | This method calls the L<uv_handle_get_type|https://docs.libuv.org/en/v1.x/handle.html#c.uv_handle_get_type> function. | ||
| 58 | |||
| 59 | =head1 Well Known Child Classes | ||
| 60 | |||
| 61 | =over 2 | ||
| 62 | |||
| 63 | =item * L<UV::Handle::Async|SPVM::UV::Handle::Async> | ||
| 64 | |||
| 65 | =item * L<UV::Handle::Idle|SPVM::UV::Handle::Idle> | ||
| 66 | |||
| 67 | =item * L<UV::Handle::Pipe|SPVM::UV::Handle::Pipe> | ||
| 68 | |||
| 69 | =item * L<UV::Handle::Poll|SPVM::UV::Handle::Poll> | ||
| 70 | |||
| 71 | =item * L<UV::Handle::Stream|SPVM::UV::Handle::Stream> | ||
| 72 | |||
| 73 | =item * L<UV::Handle::Timer|SPVM::UV::Handle::Timer> | ||
| 74 | |||
| 75 | =back | ||
| 76 | |||
| 77 | =head1 Copyright & License | ||
| 78 | |||
| 79 | Copyright (c) 2026 Yuki Kimoto | ||
| 80 | |||
| 81 | MIT License |