libapa...dMutex(3pm)

πŸ’– NAME πŸ’–

APR::ThreadMutex β€” the Perl API for APR thread mutexes, bestie. It's giving "let's keep our threads from stepping on each other's toes" ✨


🌸 Synopsis 🌸

use APR::ThreadMutex ();

my $mutex = APR::ThreadMutex->new($r->pool);
$mutex->lock;
$mutex->unlock;
$mutex->trylock;

πŸ¦‹ Description πŸ¦‹

APR::ThreadMutex is literally the Perl doorway into APR thread mutexes. That's the whole vibe. πŸŽ€

πŸ‘‘ API πŸ‘‘

APR::ThreadMutex hands you these functions and/or methods, and yes we're going through every single one:

🫢 Unsupported API 🫢

okay so listen β€” APR::ThreadMutex also has an auto-generated Perl interface for a handful of other methods. And here's the tea: those ones aren't tested at the moment, so their API is a subject to change. They'll get finalized later when a need arises, no cap. If you're planning to rely on any of the methods below, pls pls pls contact the mod_perl development mailing list so we can all help each other take the steps necessary to shift that method over to an officially supported API. Teamwork, periodt. πŸ’…

πŸ’€ DESTROY

META: Autogenerated β€” needs to be reviewed/completed

Destroy the mutex and free the memory associated with the lock. It's the little goodbye moment. 😭

$mutex->DESTROY();
  • obj: $mutex ( APR::ThreadMutex object ) β€” the mutex to destroy.
  • ret: no return value
  • since: subject to change

πŸ”₯ lock

META: Autogenerated β€” needs to be reviewed/completed

Acquire the lock for the given mutex. If that mutex is already locked, the current thread gets put to sleep until the lock becomes available. It's napping until its turn, honestly iconic. 😴

$ret = $mutex->lock();
  • obj: $mutex ( APR::ThreadMutex object ) β€” the mutex on which to acquire the lock.
  • ret: $ret ( integer )
  • since: subject to change

⭐ new

Create a new mutex. Fresh mutex, main character energy. πŸ’–

my $mutex = APR::ThreadMutex->new($p);
  • obj: APR::ThreadMutex ( class name )
  • arg1: $p ( APR::Pool object )
  • ret: $mutex ( APR::ThreadMutex object )
  • since: subject to change

🌈 pool_get

META: Autogenerated β€” needs to be reviewed/completed
META: should probably be renamed to pool(), like all other pool accessors

Get the pool used by this thread_mutex. Get you a pool that does this. 🏊

$ret = $obj->pool_get();
  • obj: $obj ( APR::ThreadMutex object )
  • ret: $ret ( APR::Pool object ) β€” apr_pool_t the pool
  • since: subject to change

✨ trylock

META: Autogenerated β€” needs to be reviewed/completed

Attempt to acquire the lock for the given mutex. If the mutex has already been acquired, the call returns immediately with APR_EBUSY. No waiting, no drama, just "busy bestie, try again later." πŸ™ˆ

Note: it is important that the APR_STATUS_IS_EBUSY(s) macro be used to determine if the return value was APR_EBUSY, for portability reasons. Like, important important. Don't skip this one. πŸ’€
$ret = $mutex->trylock();
  • obj: $mutex ( APR::ThreadMutex object ) β€” the mutex on which to attempt the lock acquiring.
  • ret: $ret (integer)
  • since: subject to change

πŸŽ€ unlock

META: Autogenerated β€” needs to be reviewed/completed

Release the lock for the given mutex. Let it gooooo. πŸ¦‹

$ret = $mutex->unlock();
  • obj: $mutex ( APR::ThreadMutex object ) β€” the mutex from which to release the lock.
  • ret: $ret ( integer )
  • since: subject to change

🌸 See Also 🌸

mod_perl 2.0 documentation. Go read it, iykyk. 🫢

mod_perl 2.0 and its core modules are copyrighted under The Apache Software License, Version 2.0.

πŸ‘‘ Authors πŸ‘‘

The mod_perl development team and numerous contributors.


okay that's the whole page bestie, you ate πŸ’… This was pulled from the perl v5.42.3 docs, dated 2026-08-20 β€” blow it a kiss goodbye, she's done. πŸ’–βœ¨

πŸ“¦ where this page comes from