Created
June 28, 2018 17:01
-
-
Save jef-sure/50618799dba3e7f16692e463f5e24b33 to your computer and use it in GitHub Desktop.
This file contains hidden or 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