NAME
VS::RuleEngine::Runloop - Runs engine(s)
SYNOPSIS
use VS::RuleEngine::Runloop;
my $engine1 = MyApp::Engine->get_engine();
my $engine2 = MyApp::Engine->get_another_engine();
my $runloop = VS::RuleEngine::Runloop->new();
$runloop->add_engine($engine1);
$runloop->add_engine($engine2);
# Run the two engines until there's no more processing
# to be done in either of them
$runloop->run();
DESCRIPTION
This class converts engine descriptions (VS::RuleEngine::Engine
-instances) into something runnable and executes them.
If multiple engines are defined in a single runloop execution will continue until no engines have anything ore to process. Engines that report they are done processing are removed from the runloop.
INTERFACE
CLASS METHODS
- new
-
Creates a new runloop instance.
INSTANCE METHODS
- add_engine ( ENGINE [, GLOBALS] )
-
Adds an engine to the runloop. An optional VS::RuleEngine::Data instance can be passed as global data for the engine. If omitted a empty VS::RuleEngine::Data instance will be created and used as global.
- init
-
Initializes the runloop. Must be called before
step
in order for the runloop to work. It called automaticly byrun
. - step
-
Performs one iteration in the runloop. Returns the number of engines that are still in the runloop. When there is no more work to be done it returns 0.
- run
-
Runs the engine until there is no more work to perform.