Manpage logo

SPVM::Document::NativeAPI::Mutex - Mutex Native APIs

Name  Description  Usage  Details  Native APIs  new_instance  free_instance  lock  unlock  reader_lock  reader_unlock  Native API IDs  See Also  Copyright & License 

Name

SPVM::Document::NativeAPI::Mutex − Mutex Native APIs

Description

The mutex native APIs in SPVM are the APIs for mutex.

Usage

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);

Details

These APIs implements read−write locks in Linux and UNIX and slim reader/writer (SRW) locks <https://learn.microsoft.com/en-us/windows/win32/sync/slim-reader-writer--srw--locks> in Windows.

Native APIs

new_instance

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

Creates a new mutex and initialize it, and returns it.

free_instance

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

Destroys the mutex mutex and frees it.

lock

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

Locks the mutex mutex.

Calls the pthread_rwlock_wrlock <https://linux.die.net/man/3/pthread_rwlock_wrlock> function in Linux and UNIX.

Calls AcquireSRWLockExclusive <https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-acquiresrwlockexclusive> function in Windows.

unlock

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

Unlocks the mutex mutex.

Calls the pthread_rwlock_unlock <https://linux.die.net/man/3/pthread_rwlock_unlock> function in Linux and UNIX.

Calls ReleaseSRWLockExclusive <https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-releasesrwlockexclusive> function in Windows.

reader_lock

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

Locks the mutex mutex for reading.

Calls the pthread_rwlock_rdlock <https://linux.die.net/man/3/pthread_rwlock_rdlock> function in Linux and UNIX.

Calls AcquireSRWLockShared <https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-acquiresrwlockshared> function in Windows.

reader_unlock

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

Unlocks the mutex mutex for reading.

Calls the pthread_rwlock_unlock <https://linux.die.net/man/3/pthread_rwlock_unlock> function in Linux and UNIX.

Calls ReleaseSRWLockShared <https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-releasesrwlockshared> function in Windows.

Native API IDs

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

Copyright & License

Copyright (c) 2023 Yuki Kimoto

MIT License


Updated 2026-06-01 - jenkler.se | uex.se