The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

BusyBird::Watcher - interface for watcher objects

SYNOPSIS

    my $watcher = $timeline->watch_unacked_counts(
        assumed => { total => 0 },
        callback => sub { ... }
    );
    
    $watcher->active;   ## returns true if the $watcher is active
    $watcher->cancel(); ## cancels the $watcher

DESCRIPTION

This is an interface (or role) class for watcher objects. A watcher is something that represents a callback registered somewhere. Users can use a watcher to cancel (i.e. unregister) the callback.

BusyBird::Watcher does not implement any method. Implementations of BusyBird::Watcher must be a subclass of BusyBird::Watcher and implement the following methods.

OBJECT METHODS

$is_active = $watcher->active()

Returns true if the $watcher is active. Returns false otherwise.

An active watcher is the one whose callback can be called. On the other hand, the callback of an inactive watcher will never be called.

$watcher->cancel()

Cancels the $watcher, that is, makes it inactive.

If $watcher is already inactive, it stays inactive.

AUTHOR

Toshio Ito <toshioito [at] cpan.org>