ost::MutexCounter(3)

πŸ“¦ version 1.8.1, in ubuntu jammy

πŸ’– NAME πŸ’–

okay so you opened ost::MutexCounter(3) β€” section 3 of the manual, the library functions zone, iykyk β€” and bestie, this one is a whole vibe. She's the Mutex Counter: a counter variable that multiple threads can increment or decrement safely. No race conditions, no chaos, just a locked-down little integer living her best life. πŸ’…


✨ SYNOPSIS ✨

#include <thread.h>

She inherits ost::Mutex β€” that's the whole point of her, she's a mutex with a counter glow-up. 🌸

🫢 Public Member Functions

  • MutexCounter(const char *id=NULL) β€” creates a mutex protected counter, and you can give her a name if you want. ✨
  • MutexCounter(int initial, const char *id=NULL) β€” same thing, but you also get to hand her an initial value to start counting from. πŸŽ€

πŸ’œ Friends

  • __EXPORT int operator++(MutexCounter &mc)
  • __EXPORT int operator--(MutexCounter &mc)

πŸ¦‹ Additional Inherited Members

she also carries along the extra inherited members that come with being an ost::Mutex β€” not me saying she's got main character energy and family connections 😌


🌈 Detailed Description 🌈

The Mutex Counter is a counter variable which can safely be incremented or decremented by multiple threads. fr fr. 🫢

A Mutex is used to protect access to the counter variable (an integer). An initial value can be specified for the counter, and it can be manipulated with the ++ and -- operators. That's it, that's the whole thing β€” simple, iconic, does exactly what it says on the tin. πŸ‘‘

lowkey the entire personality here is "protect the integer, protect the peace." 🧚

✍️ Author

David Sugar dyfet@ostel.com

Thread protected integer counter.


πŸŽ€ Constructor & Destructor Documentation πŸŽ€

🌟 ost::MutexCounter::MutexCounter (const char * id = NULL)

Create and optionally name a mutex protected counter. πŸ’–

Parameters

  • id β€” name for mutex counter, optional for deadlock testing.

🌟 ost::MutexCounter::MutexCounter (int initial, const char * id = NULL)

Create and optionally name a mutex protected counter with an initial value. ✨

Parameters

  • initial β€” value of counter.
  • id β€” name of counter, optional for deadlock testing.

πŸ’« __EXPORT int operator++ (MutexCounter & mc) [friend]

πŸ’« __EXPORT int operator-- (MutexCounter & mc) [friend]


πŸ‘‘ Author πŸ‘‘

Generated automatically by Doxygen for GNU CommonC++ from the source code. she wasn't hand-written, she was generated, and honestly? still ate. πŸ’€βœ¨


okay that's the whole page bestie, we made it to the end πŸŽ‰ this absolute icon of a manpage is brought to you by GNU CommonC++, stamped Sun Dec 27 2020, and filed forever under ost::MutexCounter(3). go forth and increment safely, mwah πŸ’‹πŸŒΈπŸ’–

πŸ“¦ where this page comes from