Script Index


/var/lib/sorcery/modules/libdepengine

In the simple model, without triggers, we color graph nodes (spells) white, and as we recursiely visit them, mark them grey. When all of a spell's children have been visited, and successfully cast, we cast the spell, and mark the node either black:0 or black: (eg black:34) for success or failure respectively. If a child fails we mark the current node black: and return. In the case that we visit a child that is grey, a dependency loop is detected, currently we ignore it and build the tail spell anyway, in the future we could break optional depends and cast some spell twice. The more complex model implemented below includes the above, but after a spell builds (or fails), it colors itself brown and executes its triggers. This is a little more complicated because there could be multiple triggers on a single spell and cycles are frequent. If successful, the spell marks each trigger as a 'pending trigger' . Then if that spell is the last triggerer, the trigger is registered (possibly from another spell), and the trigger is not grey (depends cycle, indicating it is unsafe to cast the spell) the spell is cast in a special variant of the above algorithm. The key difference is that if a grey node is encountered (depends cycle), instead of breaking it, the spell gracefully backs off and the trigger is left on the pending triggers list while other triggers are executed. All the triggers for the spell are executed similarly until there are no triggers left, or no progress is made. If after all spells are cast there are still pending triggers they are built at that point without the graceful cycle handling.

Synopsis

Implements sorcery's dependency/trigger tree walking engine.


function depengine_entry_point()

Parameters:

Description

This is the entry point for the dependency engine, it handles top level tasks. It invokes the cast_engine on each requested spell and cleans up any left-over pending triggers.


function depengine_cast_engine()

Parameters:

Description

Top level routine for executing a graph node Builds the children, then itself, then executes triggers.


function recurse_depends()

Parameters:

global

MINUS_K if 'yes', then act like make -k and continue building dependent spells even if another one fails.

Description

Iterative recursive step. Build each of the spell's dependencies.


function execute_triggers()

Parameters:

Description

Attempt to run all this spell's triggers. Some triggers may not be runable at this time, or it may be better to run them later.


function dpgn_cast_spell_front()

Parameters:

Description

frontend to cast spells, unregisters pending triggers if any


function dpgn_set_spell_color()

Parameters:

Description

set the spell color


function dpgn_get_spell_color()

Parameters:

Description

get the spell color


function dpgn_register_pending_trigger()

Parameters:

Description

Mark this spell as a pending trigger


function dpgn_is_pending_trigger_registered()

Parameters:

Description

determine if a trigger is pending or not


function dpgn_unregister_pending_trigger()

Parameters:

Description

mark spell as no longer needing a trigger


function dpgn_get_all_pending_triggers()

Parameters:

Description

return all the pending triggers