Fsdb::S...::Freds(3)
π NAME π
okay so bestie, welcome to Fsdb::S...::Freds(3) β that's the manual name, and it's user-contributed Perl documentation. The actual package is Fsdb::Support::Freds: an abstraction over fork and/or ithreads. That's the whole name vibe. Periodt. π
πΈ SYNOPSIS πΈ
use Fsdb::Support::Freds;
my $fred = new Fsdb::Support::Freds('new thread to do foo');
# or
my $fred = new Fsdb::Support::Freds('demo_fred',
sub { child_stuff(); exit 0; },
sub { say "child is done\n"; } );
$fred->join();
# or
$fred->detach();
okay so this package gives you an abstraction over fork that is something like Perl's ithreads. Our goal is to abstract process creation and collection, but none of the shared data like ithreads. No cap.
(Why "Freds"? Because it's fork-based thread-like things, and "Tasks" seems too generic. iykyk.) π¦
π new π
$fsdb = new Fsdb::Support::Freds($description, $child_sub, $ending_sub);
For a process, labeling it with optional $DESCRIPTION, then running optional $CHILD_SUB in the subprocess, then running optional $ENDING_SUB in the parent process when it exits. slay.
$ENDING_SUB is passed three arguments: the fred, the shell exit code (typically 0 for success or non-zero for failure), and the wait return code (the shell exit code shifted, plus signal number). important!
It is the job of the $CHILD_SUB to exit if it wants. Otherwise this function returns to the caller. fr fr.
π¦ is_child π¦
$fred->is_child();
Are we the child? Returns undef if parent. iconic little check.
πΈ info πΈ
$info = $fred->info();
Return a string description of the Fred. cute.
π error π
$fred->error();
Non-zero if in error state. vibe check failed.
π exit_code π
$fred->exit_code($full);
Exit code of a termintated fred. With $FULL, turn the full version (including errors). Typically "0" means success. got it.
π§ _post_join π§
$fred->_post_join();
Internal cleanup after $FRED is terminated. internal business, bestie.
π₯ join π₯
$fred->join();
Join a fred (wait for the process to finish). Returns -1 on error (Including if not in the parent.) so watch out if you're not the parent.
β join_any β
my $fred = Fsdb::Support::Freds::join_any($BLOCK);
Join on some pending fred, without blocking (default) or blocking (if $BLOCK) is set. Returns -1 on error. Returns 0 if something is running but not finished.
Returns the $FRED that ends. this one hands you the fred that ends!
π join_all π
my $fred = Fsdb::Support::Freds::join_all();
Reap all pending threads. clean up the whole group chat.
π END π
Detect any non-reaped processes. last vibe check.
bye bestie π β this Fsdb::S...::Freds(3) page is from perl v5.32.1, dated 2024-08-02.
π¦ where this page comes from
- epel 9: perl-Fsdb 2:3.9-1.el9 Β· GPLv2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms