NAME

App::PerlWatcher::Watcher - Observes some external source of events and emits the result of polling them

VERSION

version 0.18

ATTRIBUTES

engine_config

Holds an reference to engine config (used in construction watcher's thresholds_map)

init_args

Remembers the arguments for watcher construction (used in construction watcher's thresholds_map and unique_id)

config

The wacher configuration hash ref.

unique_id

Represents watchers unique_id, calculated from concrete watcher class and watcher's config. The unique_id is overloaded "to-string" operation, so watcher can be used to as hash key. unique_id is also used when the PerlWatcher state is been persisted : the watcher itself isn't stored, but it's unique_id is stored. That guarantees that unique_id is the same between PerlWatcher invokations (that's why the perl internal hash funciton isn't used)

memory

Stores current wacher state (memory). When the watcher is persisted, only it's memory and unique_id are stored.

callback

The subroutine reference, which is been called on every poll of watcher external source. It's argument is the State.

watcher_guard

The watcher guard returned by AnyEvent->io, AnyEvent->timer etc, with is an core under wich the Watcher is been build.

METHODS

build_watcher_guard

The method is responsible for building watcher_guard

force_poll

Immediatly polls the watched object.

active

Turns on and off the wacher.

start

Starts the watcher, which will emit it's statuses. The watcher will start only it is active.

calculate_threshods

Calculates the thresholds_map based on the left map and righ map The left map has precedence. Usualy the left map is the watchers config, while the righ map is the generic PerlWatcher/Engine config

interpret_result

This method interprets the result of poll (true or false) in accordance with thresholds_map and the callback will be called with the resulting status (and optionally provided items). Meant to be called from subclases, e.g.

$watcher->interpret_result(0, $callback);

AUTHOR

Ivan Baidakou <dmol@gmx.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Ivan Baidakou.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.