SbRWMutex(3)

πŸ“¦ version 3.1.3, in fedora 43, fedora 44

πŸ’– 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