globus_thread_key(3)

πŸ“¦
version 18.15 Β· 6 versions
, in epel 10, fedora 43, fedora 44, ubuntu resolute, ubuntu stonking

πŸ’– globus_thread_key β€” thread-specific storage, bestie edition πŸ’–

okay so this is globus_thread_key(3) from the Library Functions Manual, and it's literally the whole vibe of "every thread gets its own lil drawer of stuff" πŸ”₯ stay with me.

✨ NAME ✨

globus_thread_key β€” Thread-Specific Storage

  • Thread-Specific Storage.

periodt. that's the name, that's the whole thing πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

functions, bb πŸ¦‹

  • int globus_thread_key_create (globus_thread_key_t *key, globus_thread_key_destructor_func_t destructor) β€” create a key for thread-specific storage.
  • int globus_thread_key_delete (globus_thread_key_t key) β€” delete a thread-local storage key.
  • void * globus_thread_getspecific (globus_thread_key_t key) β€” get a thread-specific data value.
  • int globus_thread_setspecific (globus_thread_key_t key, void *value) β€” set a thread-specific data value.
int globus_thread_key_create (globus_thread_key_t *key,
    globus_thread_key_destructor_func_t destructor)
int globus_thread_key_delete (globus_thread_key_t key)
void * globus_thread_getspecific (globus_thread_key_t key)
int globus_thread_setspecific (globus_thread_key_t key, void *value)

🌸 Detailed Description 🌸

Thread-Specific Storage. yes we're saying it again, it's iconic.

The globus_thread_key_t data type acts as a key to thread-specific storage. For each key created by globus_thread_key_create(), each thread may store and retrieve its own value. like a group chat where everyone has their own private notes but the chat is shared, iykyk 🫢


πŸ‘‘ Function Documentation πŸ‘‘

πŸ’œ void * globus_thread_getspecific (globus_thread_key_t key)

Get a thread-specific data value. The globus_thread_getspecific() function returns the value associated with the thread-specific data key passed as its first parameter. This function returns NULL if the value has not been set by the current thread. The return value is undefined if the key is not valid. 😭 so if your key is trash, whatever comes back is not to be trusted, fr fr.

Parameters

  • key β€” Thread-specific data key to look up.

Returns

The value passed to a previous call to globus_thread_setspecific() in the current thread for this key. like it remembers what you put in there, bestie πŸ’–


πŸ¦‹ int globus_thread_key_create (globus_thread_key_t * key, globus_thread_key_destructor_func_t destructor)

Create a key for thread-specific storage. The globus_thread_key_create() function creates a new key for thread-specific data. The new key will be available for all threads to store a distinct value. If the function pointer destructor is non-NULL, then that function will be invoked when a thread exits that has a non-NULL value associated with the key. so yes, you get a lil cleanup fairy 🧚 for when a thread dips out.

Parameters

  • key β€” Pointer to be set to the new key.
  • destructor β€” Pointer to a function to call when a thread exits to free the key's value.

Returns

On success, globus_thread_create_key() will create a new key to thread-local storage and return GLOBUS_SUCCESS. If an error occurs, then the value of key is undefined and globus_thread_create_key() returns an implementation-specific non-zero error value.

heads up bestie: if it errors, the value of key is undefined, so do not go touching it like it's fine πŸ™ˆ

🌈 int globus_thread_key_delete (globus_thread_key_t key)

Delete a thread-local storage key. The globus_thread_key_delete() function deletes the key used for a thread-local storage association. The destructor function for this key will no longer be called after this function returns. The behavior of subsequent calls to globus_thread_getspecific() or globus_thread_setspecific() with this key will be undefined. 🩷 like ma'am, the key is gone, stop calling it, the behavior is undefined and that's not a cute look.

Parameters

  • key β€” Key to destroy.

Returns

On success, globus_thread_key_delete() will delete a thread-local storage key and return GLOBUS_SUCCESS. If an error occurs, then the value of key is undefined and globus_thread_create_key() returns an implementation-specific non-zero error value.

(yes it really does say globus_thread_create_key() in that Returns line, i am not editing the source, i am simply reporting it πŸ’€)

⭐ int globus_thread_setspecific (globus_thread_key_t key, void * value)

Set a thread-specific data value. The globus_thread_setspecific() function associates a thread-specific value with a data key. If the key had a previous value set in the current thread, it is replaced, but the destructor function is not called for the old value. okay so lowkey the old value just gets ghosted and the destructor does NOT run for it, noted ✨

Parameters

  • key β€” Thread-specific data key to store.
  • value β€” A pointer to data to store as the thread-specific data for this thread.

Returns

On success, globus_thread_setspecific() stores value in the thread-specific data for the specified key and returns GLOBUS_SUCCESS. If an error occurs, globus_thread_setspecific() returns an implementation-specific non-zero error code and does not modify the key's value for this thread. so worst case your old value stays put, no chaos 🫢


🌟 Author 🌟

Generated automatically by Doxygen for globus_common from the source code. so like, a robot wrote this about a robot library, slay πŸ€–πŸ’…


and that's the whole page!! this was globus_common, Version 18.15, from the globus_thread_key(3) manual page β€” thanks for reading bestie, go forth and give every thread its own lil storage drawer πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈ