Storable(3pm)
π Storable(3pm) β Coro::Storable π
okay bestie, so this is a page from the User Contributed Perl Documentation section of the manual, and it's about Coro::Storable, which is giving "Storable but make it cooperative" energy. let's get into it π«Ά
β¨ NAME β¨
Coro::Storable β offer a more fine-grained Storable interface π
πΈ SYNOPSIS πΈ
use Coro::Storable;
that's literally it. one line. she's low maintenance. π
π¦ DESCRIPTION π¦
so this module implements a few functions from the Storable module, but in a way that cedes more often. because sometimes β and hear me out β some applications (like the Deliantra game server, for example) need to load large Storable objects without blocking the server for a long, long time. and blocking the server? not the vibe. not today. π
the way it does this is by using a perlio layer that feeds only small amounts of data into Storable β specifically 4096 bytes per call β and calling Coro::cede regularly. how regularly, you ask? at most 100 times per second by default, though. so like, she's polite about it. β¨
now here's the important part, and I need you to really hear me on this: Storable is not reentrant. so this module also wraps most functions of the Storable module so that only one freeze or thaw happens at any one moment. and jsyk β recursive invocations are not currently supported. that's a real limitation, not a cute quirk. π
π FUNCTIONS π
π $ref = thaw $pst
retrieve an object from the given $pst, which must have been created with Coro::Storable::freeze or Storable::store_fd / Storable::store. and yeah, sorry bestie β Storable uses incompatible formats for disk and memory objects, so you can't just mix and match. π
this function will cede regularly. π
π $pst = freeze $ref
freeze the given scalar $ref into a Storable object. it uses the same format as Storable::store_fd.
this functino will cede regularly. (yes, "functino". the original really said that and honestly? iconic typo. we're keeping it. π)
π $pst = nfreeze $ref
same as freeze, but it's compatible with Storable::nstore_fd β and note the n, bestie, the n is doing heavy lifting here. π
π $pst = blocking_freeze $ref
same as freeze, but it is guaranteed to block. and that's actually a feature, not a bug β it's useful e.g. in Coro::Util::fork_eval when you want to serialise a data structure for use with the thaw function for this module. β
you cannot use Storable::freeze for this, because Storable uses incompatible formats for memory and file images, and this module uses file images. so like, don't. fr fr. π
π $pst = blocking_nfreeze $ref
same as blocking_freeze, but it uses nfreeze internally. π
π $guard = guard
acquire the Storable lock β for when you want to call Storable yourself. main character energy, going in solo. π
but ngl, note that this module already wraps all Storable functions, so there is rarely any need to do this yourself. the lock is right there. she's handled. π«Ά
π AUTHOR/SUPPORT/CONTACT π
Marc A. Lehmann <schmorp@schmorp.de>
http://software.schmorp.de/pkg/Coro.html
and that's the whole page, bestie!! no cap, every flag and function accounted for. this one came out of perl v5.40.1, dated 2025-03-21, under the Storable(3pm) name β so if you cite her, cite her right. mwah. πβ¨π
π¦ where this page comes from
- debian trixie: libcoro-perl 6.570-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libcoro-perl 6.570-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms