Pipelin...::Async(3)
β¨ NAME β¨
Pipeline::Segment::Async β asynchronous pipeline segments π
So this is from the User Contributed Perl Documentation manual, section 3 (that's the library-functions girlies, not the shell-command ones). Anyway. Buckle up bestie, we're going async π¦
πΈ SYNOPSIS πΈ
my $seg = $pipe->store->get( $async_segment_classname );
my $ret = $seg->reattach();
That's literally it. Grab it, reattach it, get your lil return values back. Periodt β¨
π DESCRIPTION π
Okay so Pipeline::Segment::Async is the module that lets you write asynchronous pipeline segments. Whenever an async segment gets dispatched, it puts itself into the store, and then it splits away from the main process β which just keeps on running like nothing happened. main character energy fr π
At any point further down the pipeline, you can request that segment back from the store, and then ask it to hand over its return values by calling reattach(). Or β if you're feeling chaotic β you can just throw them away entirely with discard(), which will simply destroy the segment when it completes. ποΈ
β οΈ But listen, bestie: if you call discard(), there is no way you can get it back. None. It's gone. Grieve and move on π
You add an async segment to a pipeline in exactly the same manner you'd add any other segment. It gets dispatched the normal way, with the normal arguments supplied to the dispatch method. Getting objects from the store will retrieve them as expected β however, altering those objects or setting them back into the store will not do what you expect. Lowkey a trap, highkey important π
Pipeline::Segment::Async works by indicating to the dispatcher that it wants a different method to be its dispatch method. And here's the plot twist: if you indicate to the dispatcher that you want something to dispatch different at the segment level, then your asynchronous segment will become decidedly synchronous. Not me gaslighting my own async code π
Pipeline::Segment::Async inherits from Pipeline::Base and has any methods that it provides. Inheritance, slay π«Ά
π METHODS π
init()βinit()is called by the constructor, and it sets up the list of threading models thatPipeline::Segment::Asyncis aware of. Peepthreading_models()for more info π₯threading_models( [ARRAYREF] )βthreading_models()gets and sets a list of classes that know how to process segements asynchronously.predispatch()βpredispatch()is called by the pipeline dispatcher and prepares the segment for asynchronous execution. Pre-game ritual, basically β¨model( [Pipeline::Segment::Async::*] )βmodel()returns an object that represents the threading model thatPipeline::Segment::Asyncwill call. If it doesn't yet have an object, a call todetermine_threading_model()is called. It'll go find one for you, don't stress πdetermine_threading_model()βdetermine_threading_model()will look at all the classes in the list provided bythreading_models()and determine if they can operate under the current configuration. It will return an object of one of those classes, provided it can operate. Vibe check on every single candidate πreattach()βreattach()takes a detached asynchronous segment and joins it back, placing the results in the correct area of the pipeline. The reunion arc we've all been waiting for π₯Ήdiscard()βdiscard()flags an asynchronous segment as never needing to be reattached. Bye forever bestie, no takebacks πdispatch_method()βdispatch_method()tells the pipeline dispatch class which method to call in order to dispatch this class. In the case ofPipeline::Segment::Asyncit returns a constant with the valuepredispatch.
π¦ SEE ALSO π¦
Pipeline::Segment, Pipeline::Dispatch, Pipeline::Base, Pipeline::Segment::Async::Handler
Go read those too, iykyk π
β AUTHOR β
James A. Duncan <jduncan@fotango.com> β the icon, the legend π«
π COPYRIGHT π
Copyright 2003 Fotango Ltd. All Rights Reserved.
This software is released under the same terms as Perl itself. π
And that's the whole page, bestie β documented by User Contributed Perl Documentation, from the perl v5.42.0 era, dated 2025-07-25. Go forth and async responsibly πβ¨πΈ
π¦ where this page comes from
- fedora 43: perl-Pipeline 3.12-51.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms