Timer::Breakable - Timed block calls that can be broken externally.
use Timer::Breakable;
my $timer = Timer::Breakable.start( 10, { say "Times up" } );
... Stuff occurs ...
$timer.stop if $variable-from-stuff;
say $timer.result if $timer.status ~~ Kept;
Timer::Breakable is wrapper aroud the standard Promise.in() functionality that lets you stop the timer without running it's block.
A vowed promise that can be handed to await, anyof or allof. Note that the promises status and results can be accessed from the Timer::Breakable object directly.
Factory method to start the timer. Expects the time to run and the block to run on completion.
Stops the timer. Note that the timer itself will still run to completion but the given block will not be run.
As per Promise.status()
As per Promise.result()
Version 0.1.0 updated the object creation to use start as a factory method.
Simon Proctor [email protected]
Copyright 2017 Simon Proctor
This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.