PTHREAD...DESTROY(3POSIX)

πŸ’… PROLOG πŸ’…

ok bestie so before we even get into it β€” this manual page is part of the POSIX Programmer's Manual. that's the tea. the Linux implementation of this interface may differ, so if you're on Linux pls go consult the corresponding Linux manual page for the deets on Linux behavior. also possible: the interface just isn't implemented on Linux at all. vibe check accordingly. 🫢


✨ NAME ✨

pthread_rwlockattr_destroy, pthread_rwlockattr_init β€” destroy and initialize the read-write lock attributes object


🌸 SYNOPSIS 🌸

#include <pthread.h>

int pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr);
int pthread_rwlockattr_init(pthread_rwlockattr_t *attr);

πŸŽ€ DESCRIPTION πŸŽ€

ok so like. two functions, one bestie duo, both about the attributes object for a read-write lock. not the lock itself. the ✨attributes✨. important distinction, iykyk.

  • pthread_rwlockattr_destroy() β€” this one shall destroy a read-write lock attributes object. yes, destroy. rip. but here's the cute part: a destroyed attr attributes object can be reinitialized using pthread_rwlockattr_init(). the results of otherwise referencing the object after it has been destroyed are undefined πŸ’€ so like, don't do that. also, an implementation may cause pthread_rwlockattr_destroy() to set the object referenced by attr to an invalid value.
  • pthread_rwlockattr_init() β€” this one shall initialize a read-write lock attributes object attr with the default value for all of the attributes defined by the implementation. defaults, slay.
⚠️ Results are undefined if pthread_rwlockattr_init() is called specifying an already initialized attr attributes object. don't double-init, that's not the move bestie.

and this next bit is lowkey the most important thing here: after a read-write lock attributes object has been used to initialize one or more read-write locks, any function affecting the attributes object (including destruction) shall not affect any previously initialized read-write locks. the locks are independent, they're grown, they don't need the attr anymore. main character energy honestly. πŸ‘‘

🚨 The behavior is undefined if the value specified by the attr argument to pthread_rwlockattr_destroy() does not refer to an initialized read-write lock attributes object. like. it has to actually be an initialized rwlock attributes object. that's the whole prerequisite. no cap.

πŸ”₯ RETURN VALUE πŸ”₯

if everything goes well, both pthread_rwlockattr_destroy() and pthread_rwlockattr_init() shall return zero. otherwise? an error number shall be returned to indicate the error. that's it, that's the return value system. ✨


πŸ’€ ERRORS πŸ’€

pthread_rwlockattr_init() shall fail if:

  • ENOMEM β€” insufficient memory exists to initialize the read-write lock attributes object. 😭 out of memory, out of luck.

and one very specific thing: these functions shall not return an error code of [EINTR]. periodt.

πŸ“Œ The following sections are informative.

🌈 EXAMPLES 🌈

None.

like. literally none. nothing to show. iconic of them honestly. πŸ¦‹


πŸ’œ APPLICATION USAGE πŸ’œ

None.

again. nothing. moving on bestie. πŸ™ˆ


⭐ RATIONALE ⭐

so if an implementation detects that the value specified by the attr argument to pthread_rwlockattr_destroy() does not refer to an initialized read-write lock attributes object, it is recommended that the function should fail and report an [EINVAL] error.

(recommended, bestie. not shall. we're being polite about it.) πŸŽ€


🧚 FUTURE DIRECTIONS 🧚

None.

nothing coming down the pipeline. the future is quiet. πŸ“


πŸ‘‘ SEE ALSO πŸ‘‘

  • pthread_rwlock_destroy()
  • pthread_rwlockattr_getpshared()

and the Base Definitions volume of POSIX.1‐2017, <pthread.h> β€” go read it, it's giving reference material. πŸ“š


Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


ok that's the whole page, you're welcome bestie 🫢 this one came from IEEE/The Open Group, 2017 β€” yes the 2017 date, yes the same crew, and the page itself answers to the name PTHREAD...DESTROY(3POSIX). go forth and initialize responsibly πŸ’…βœ¨