Fsdb::S...::Freds(3)

πŸ“¦
version 3.9 Β· 3 versions
, in epel 9

πŸ’– 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