| 1 | package SPVM::Sys::Time::Timeval; | ||
| 2 | |||
| 3 | 1; | ||
| 4 | |||
| 5 | =head1 Name | ||
| 6 | |||
| 7 | SPVM::Sys::Time::Timeval - struct timeval in the C language | ||
| 8 | |||
| 9 | =head1 Description | ||
| 10 | |||
| 11 | Sys::Time::Timeval class in L<SPVM> represents L<struct timeval|https://linux.die.net/man/2/gettimeofday> in the C language. | ||
| 12 | |||
| 13 | =head1 Usage | ||
| 14 | |||
| 15 | use Sys::Time::Timeval; | ||
| 16 | |||
| 17 | my $tv = Sys::Time::Timeval->new; | ||
| 18 | |||
| 19 | my $tv = Sys::Time::Timeval->new(5, 100_000); | ||
| 20 | |||
| 21 | my $tv_sec = $tv->tv_sec; | ||
| 22 | $tv->set_tv_sec(12); | ||
| 23 | |||
| 24 | my $tv_usec = $tv->tv_usec; | ||
| 25 | $tv->set_tv_usec(34); | ||
| 26 | |||
| 27 | =head1 Class Methods | ||
| 28 | |||
| 29 | =head2 new | ||
| 30 | |||
| 31 | C<static method new : L<Sys::Time::Timeval|SPVM::Sys::Time::Timeval> ($tv_sec : long = 0, $tv_usec : long = 0);> | ||
| 32 | |||
| 33 | Creates a new L<Sys::Time::Timeval|SPVM::Sys::Time::Timeval> object with the given L</"tv_sec"> and L</"tv_usec">. | ||
| 34 | |||
| 35 | Before creating the object, this method calls L</"check"> to validate the range of the arguments. If the arguments are invalid, an exception is thrown. | ||
| 36 | |||
| 37 | =head2 check | ||
| 38 | |||
| 39 | C<static method check : void ($tv_sec : long, $tv_usec : long);> | ||
| 40 | |||
| 41 | Validates the range of the given L</"tv_sec"> and L</"tv_usec">. | ||
| 42 | |||
| 43 | If L</"tv_usec"> is not greater than or equal to 0 and less than or equal to 999,999, an exception is thrown. | ||
| 44 | |||
| 45 | =head1 Instance Methods | ||
| 46 | |||
| 47 | =head2 tv_sec | ||
| 48 | |||
| 49 | C<method tv_sec : long ();> | ||
| 50 | |||
| 51 | Returns C<tv_sec>. | ||
| 52 | |||
| 53 | =head2 set_tv_sec | ||
| 54 | |||
| 55 | C<method set_tv_sec : void ($tv_sec : long);> | ||
| 56 | |||
| 57 | Sets C<tv_sec>. | ||
| 58 | |||
| 59 | =head2 tv_usec | ||
| 60 | |||
| 61 | C<method tv_usec : long ();> | ||
| 62 | |||
| 63 | Returns C<tv_usec>. | ||
| 64 | |||
| 65 | =head2 set_tv_usec | ||
| 66 | |||
| 67 | C<method set_tv_usec : void ($tv_usec : long);> | ||
| 68 | |||
| 69 | Sets C<tv_usec>. | ||
| 70 | |||
| 71 | =head2 clone | ||
| 72 | |||
| 73 | C<method clone : L<Sys::Time::Timeval|SPVM::Sys::Time::Timeval> ();> | ||
| 74 | |||
| 75 | Creates a new L<Sys::Time::Timeval|SPVM::Sys::Time::Timeval> object that is a copy of the current instance. | ||
| 76 | |||
| 77 | The new object will have the same L</"tv_sec"> and L</"tv_usec"> values as the original. | ||
| 78 | |||
| 79 | =head1 See Also | ||
| 80 | |||
| 81 | =over 2 | ||
| 82 | |||
| 83 | =item * L<Sys|SPVM::Sys> | ||
| 84 | |||
| 85 | =back | ||
| 86 | |||
| 87 | =head1 Copyright & License | ||
| 88 | |||
| 89 | Copyright (c) 2023 Yuki Kimoto | ||
| 90 | |||
| 91 | MIT License | ||
| 92 |