SPVM::D...::Mutex(3)

πŸ“¦ version 0.990125, in alpine 3.24

πŸ’… NAME

Okay bestie, so this page is all about SPVM::Document::NativeAPI::Mutex β€” the Mutex Native APIs in SPVM. It's the doc for the mutex native APIs, which are, like, the APIs for mutexes. Periodt. πŸ”’

Heads up: this page lives under User Contributed Perl Documentation β€” so it's giving community vibes, not core-perl vibes. 🫢

✨ DESCRIPTION ✨

The mutex native APIs in SPVM are the APIs for mutex. That's the whole mood. πŸŽ€


🌸 USAGE 🌸

Here's the whole flow, literally copy it exactly:

SPVM_API_MUTEX* api_mutex = env->api->mutex;

void* mutex = api_mutex->new_instance();

api_mutex->lock(env, stack, mutex);

api_mutex->unlock(env, stack, mutex);

api_mutex->free_instance(mutex);

So you grab the mutex API struct off env->api->mutex, make an instance, lock it, unlock it, free it. Iconic little lifecycle. ✨


πŸ¦‹ DETAILS πŸ¦‹

These APIs implements read-write locks in Linux and UNIX and slim reader/writer (SRW) locks in Windows. (Yes, "implements" β€” we're quoting the original vibe, don't come for me.) 😭

The SRW locks link, since you're gonna want it: https://learn.microsoft.com/en-us/windows/win32/sync/slim-reader-writer--srw--locks

So like, cross-platform locking, no cap. πŸ’œ


πŸ‘‘ NATIVE APIS πŸ‘‘

new_instance

void* (*new_instance)(SPVM_ENV* env, SPVM_VALUE* stack);

Creates a new mutex and initialize it, and returns it. Fresh mutex, main character energy. πŸ’–

free_instance

void (*free_instance)(SPVM_ENV* env, SPVM_VALUE* stack, void* mutex);

Destroys the mutex mutex and frees it. Bye bestie, we hardly knew ye. 🫢

lock

void (*lock)(SPVM_ENV* env, SPVM_VALUE* stack, void* mutex);

Locks the mutex mutex.

Calls the pthread_rwlock_wrlock function in Linux and UNIX.

Calls AcquireSRWLockExclusive function in Windows.

Link for the Linux/UNIX one: https://linux.die.net/man/3/pthread_rwlock_wrlock

Link for the Windows one: https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-acquiresrwlockexclusive

unlock

void (*unlock)(SPVM_ENV* env, SPVM_VALUE* stack, void* mutex);

Unlocks the mutex mutex. Release the lock, release the tension. πŸ’…

Calls the pthread_rwlock_unlock function in Linux and UNIX.

Calls ReleaseSRWLockExclusive function in Windows.

https://linux.die.net/man/3/pthread_rwlock_unlock

https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-releasesrwlockexclusive

reader_lock

void (*reader_lock)(SPVM_ENV* env, SPVM_VALUE* stack, void* mutex);

Locks the mutex mutex for reading. Reader mode: engaged. πŸ“–

Calls the pthread_rwlock_rdlock function in Linux and UNIX.

Calls AcquireSRWLockShared function in Windows.

https://linux.die.net/man/3/pthread_rwlock_rdlock

https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-acquiresrwlockshared

reader_unlock

void (*reader_unlock)(SPVM_ENV* env, SPVM_VALUE* stack, void* mutex);

Unlocks the mutex mutex for reading.

Calls the pthread_rwlock_unlock function in Linux and UNIX. (Yep, same function as plain unlock β€” that's not a typo, that's canon.) πŸ™ˆ

Calls ReleaseSRWLockShared function in Windows.

https://linux.die.net/man/3/pthread_rwlock_unlock

https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-releasesrwlockshared


⭐ NATIVE API IDS ⭐

These are the numeric IDs, keep them exactly as-is, iykyk:

 0 new_instance
 1 free_instance
 2 lock
 3 unlock
 4 reader_lock
 5 reader_unlock

🌈 SEE ALSO 🌈

  • SPVM::Document::NativeAPI
  • SPVM::Document::NativeClass
  • SPVM::Document

Go read those next, bestie, they're literally right there. πŸ¦‹


Copyright (c) 2023 Yuki Kimoto

MIT License


And that's the whole page, bestie!! 🌸 This was SPVM::D...::Mutex(3) from User Contributed Perl Documentation, generated with perl v5.42.2 and dated 2026-02-03. Slay, go lock something responsibly. πŸ”₯πŸ‘‘

πŸ“¦ where this page comes from