SbRWMutex(3)
π SbRWMutex π
okay bestie, so this is a page from the Library Functions Manual and it's all about SbRWMutex β the read/write mutex from Coin. yes it's threads, yes it's serious, no you're not gonna be scared of it. let's go π«Ά
β¨ SYNOPSIS β¨
#include <Inventor/threads/SbRWMutex.h>
π Public Types π
enum Precedence { READ_PRECEDENCE, WRITE_PRECEDENCE }
πΈ Public Member Functions πΈ
SbRWMutex (Precedence policy)
~SbRWMutex (void)
int writeLock (void)
SbBool tryWriteLock (void)
int writeUnlock (void)
int readLock (void)
int tryReadLock (void)
int readUnlock (void)
π¦ Detailed Description π¦
so, the SbRWMutex is a mutex that hands out both read and write access to whatever data it's protecting. and like β it's giving democracy, because multiple threads can hold read locks on the data at the same time π. but here's the plot twist: only one write-lock can ever be given out, and it cannot be handed out while a thread is holding a read lock on the data. one write-lock at a time, no exceptions, periodt π
.
and the policy for granting read locks to threads while some thread is out here waiting for the write lock? apparently that's the kind of thing that should be configurable at construction time... but which isn't at the moment. π rip. the feature is on the vision board, not in the code.
π§ Constructor & Destructor Documentation π§
β SbRWMutex::SbRWMutex (Precedence policy) [inline]
Constructor. that's it, that's the sentence. it constructs. iconic behavior honestly π
β SbRWMutex::~SbRWMutex (void ) [inline]
Destructor. it destructs. bye bestie π«Ά
π₯ Member Function Documentation π₯
π int SbRWMutex::writeLock (void ) [inline]
This one blocks the calling thread until it gains write lock status on the SbRWMutex object. so like, your thread is just gonna sit there and wait its turn. no cutting the line, no pushing π«
π SbBool SbRWMutex::tryWriteLock (void ) [inline]
tries to gain write lock status on the SbRWMutex. TRUE gets returned if it worked, FALSE if it didn't. and crucially β this is a non-blocking operation, so your thread does NOT sit around waiting. it asks, it gets an answer, it moves on. very main character energy β¨
π int SbRWMutex::writeUnlock (void ) [inline]
this method is what you use for unlocking the calling thread's write lock. give the write lock back, girl, you've had your turn π
π int SbRWMutex::readLock (void ) [inline]
blocks the calling thread until it gains read lock status on the SbRWMutex object. same waiting-room vibe as writeLock, just the read flavor πΈ
π int SbRWMutex::tryReadLock (void ) [inline]
tries to gain read lock status on the SbRWMutex. TRUE if it worked, FALSE otherwise. and again β this is a non-blocking operation π¦
π int SbRWMutex::readUnlock (void ) [inline]
this method is used for unlocking the calling thread's read lock. let somebody else read the data, sharing is caring π
π Author π
Generated automatically by Doxygen for Coin from the source code. not a human, not a bestie, just a doc generator doing its lil thing π€π
and that's the whole page, no cap. this doc came straight out of Coin, Version 3.1.3, and it was served up on the SbRWMutex(3) page of the manual. mwah, go forth and lock responsibly πβ¨π
π¦ where this page comes from
- fedora 43: Coin3-devel 3.1.3-40.fc43 Β· GPL-2.0-only
- fedora 43: Coin3-devel 3.1.3-40.fc43 Β· GPL-2.0-only
- fedora 44: Coin3-devel 3.1.3-42.fc44 Β· GPL-2.0-only
- fedora 44: Coin3-devel 3.1.3-42.fc44 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms