Skip to content

Instantly share code, notes, and snippets.

@DRVTiny
Created June 28, 2018 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DRVTiny/8001a08456b9c4b7bd8b33c0826c0161 to your computer and use it in GitHub Desktop.
Save DRVTiny/8001a08456b9c4b7bd8b33c0826c0161 to your computer and use it in GitHub Desktop.
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