ost::ThreadKey(3)

πŸ“¦ version 1.8.1, in ubuntu jammy

πŸ’– ost::ThreadKey πŸ’–

okay bestie, gather round, because we're diving into a page from the Library Functions Manual and it's giving thread-safe realness. this is ost::ThreadKey(3) and she's here to hand you a lil pointer that's all yours, per-thread, no sharing, no drama. πŸ¦‹


🌸 NAME 🌸

ost::ThreadKey β€” this class lets you create a thread-context-unique 'pointer' that can be set and retrieved, and it can be used to create thread-specific data areas for implementing 'thread safe' library routines. periodt. πŸ’…


✨ SYNOPSIS ✨

#include <thread.h>

πŸŽ€ Public Member Functions πŸŽ€

  • ThreadKey () β€” create a unique thread-specific container.
  • virtual ~ThreadKey () β€” destroy a thread-specific container and any contents reserved.
  • void * getKey (void) β€” get the value of the pointer for the thread-specific data container.
  • void setKey (void *) β€” set the value of the pointer for the current thread-specific execution context.

🫢 Friends 🫢

  • class ThreadImpl

πŸ‘‘ Detailed Description πŸ‘‘

This class allows the creation of a thread-context-unique 'pointer' that can be set and retrieved and can be used to create thread-specific data areas for implementing 'thread safe' library routines. like, imagine every thread gets its own lil locker and nobody else has the combo. iconic behavior. πŸ”₯

Finally, Common C++ supports a thread-safe AtomicCounter class. This can often be used for reference counting without having to protect the counter with a separate Mutex counter. This lends to lighter-weight code. ngl, less locking = less stress, and we love a lightweight queen. ✨

Author

  • David Sugar dyfet@ostel.com

container for thread-specific data storage. (yes, that's literally what she is. the whole vibe. πŸ’–)


🧚 Constructor & Destructor Documentation 🧚

🌈 ost::ThreadKey::ThreadKey ()

Create a unique thread-specific container. brand new, just for you, bestie. πŸŽ€

🌈 virtual ost::ThreadKey::~ThreadKey () [virtual]

Destroy a thread-specific container and any contents reserved. she's leaving, and she's taking her stuff with her. 😭


πŸ’œ Member Function Documentation πŸ’œ

🌟 void* ost::ThreadKey::getKey (void)

Get the value of the pointer for the thread-specific data container. A unique pointer can be set for each execution context. iykyk β€” your thread, your pointer, nobody else's. πŸ‘‘

Returns

  • a unique void * for each execution context. (yes, unique, fr fr. πŸ’…)

🌟 void ost::ThreadKey::setKey (void *)

Set the value of the pointer for the current thread-specific execution context. This can be used to store thread-context-specific data. drop your stuff in here, it's safe. 🫢

Parameters

  • ptr to thread-context-specific data.

⭐ friend class ThreadImpl [friend]


πŸ¦‹ Author πŸ¦‹

Generated automatically by Doxygen for GNU CommonC++ from the source code.


ok that's the whole page, bestie, no cap. every option, every signature, every return value β€” all accounted for. πŸ₯°

and a lil sign-off for the girliesss: this lil slice of the GNU CommonC++ manual is dated Sun Dec 27 2020, and the page is ost::ThreadKey(3). mwah, bye. πŸ’‹πŸŽ€βœ¨

πŸ“¦ where this page comes from