SPVM::Document::NativeAPI::Mutex − Mutex Native APIs
The mutex native APIs in SPVM are the APIs for mutex.
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);
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.
"void* (*new_instance)(SPVM_ENV* env, SPVM_VALUE* stack);"
Creates a new mutex and initialize it, and returns it.
"void (*free_instance)(SPVM_ENV* env, SPVM_VALUE* stack, void* mutex);"
Destroys the mutex mutex and frees it.
"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.
"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.
"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.
"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.
0 new_instance
1 free_instance
2 lock
3 unlock
4 reader_lock
5 reader_unlock
|
• |
SPVM::Document::NativeAPI |
|||
|
• |
SPVM::Document::NativeClass |
|||
|
• |
SPVM::Document |
Copyright (c) 2023 Yuki Kimoto
MIT License