Created
June 28, 2018 16:39
-
-
Save DRVTiny/8001a08456b9c4b7bd8b33c0826c0161 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub __set_timer { | |
my ($ptrEvID, %options) = @_; | |
my ($secAfter, $secInterval, $callback) = @options{qw/after interval cb/}; | |
return unless $secAfter or $secInterval; | |
$$ptrEvID | |
= $secAfter | |
? Mojo::IOLoop->timer( | |
$secAfter => $secInterval | |
? sub {$callback->(); $$ptrEvID = Mojo::IOLoop->recurring($secInterval => $callback)} | |
: $callback | |
) | |
: Mojo::IOLoop->recurring($secInterval => $callback); | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment