SPVM::D...::Mutex(3)
π 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::NativeAPISPVM::Document::NativeClassSPVM::Document
Go read those next, bestie, they're literally right there. π¦
π COPYRIGHT & LICENSE π
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
- alpine 3.24: spvm-doc 0.990125-r0 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms