NAME

Sub::Genius - Declarative concurrency planning for sequential Perl execution

SYNOPSIS

use Sub::Genius;

my $plan = q{ ( A B ) & ( C D ) Z };
my $sg   = Sub::Genius->new(preplan => $plan);

$sg->init_plan;
$sg->run_once;

sub A { print "A" }
sub B { print "B" }
sub C { print "C" }
sub D { print "D" }
sub Z { print "\n" }

DESCRIPTION

Sub::Genius allows you to express concurrent or partially ordered execution semantics using a declarative plan, then safely execute that plan in Perl’s uniprocess runtime.

Plans are written as Parallel Regular Expressions (PREs), which are compiled into a deterministic finite automaton (DFA). Valid execution orders are then enumerated and executed sequentially consistent with the declared constraints.

This makes it possible to:

  • Declare concurrency without threads

  • Guarantee ordering constraints without locks or atomics

  • Explore or execute all valid serializations of a concurrent plan

  • Reason about shared-memory behavior in plain Perl

Sub::Genius does not introduce real parallelism. Instead, it provides a rigorous way to describe concurrency intent and execute it safely within Perl’s single-process execution model.

QUICK EXAMPLE

my $plan = q{ A & B & C };
Sub::Genius->new(preplan => $plan)->run_any;

All permutations of A, B, and C are valid execution orders. One is chosen and executed sequentially.

WHERE TO GO NEXT

This module has a rich theoretical and practical background, including:

  • Parallel Regular Expressions (PREs)

  • Shuffle operators and partial ordering

  • Sequential consistency and uniprocess memory models

  • Finite automata construction and caching

For the full explanation, detailed examples, operator reference, runtime methods, performance considerations, and tools, see:

Sub::Genius::Extended

SEE ALSO

Sub::Genius::Extended, FLAT, Graph::PetriNet

AUTHOR

OODLER 577 <oodler@cpan.org>

LICENSE

Same terms as Perl itself.