libthr: add pshared_destroy() helper

Rewviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D38345
This commit is contained in:
Konstantin Belousov 2023-02-01 23:06:04 +02:00
parent 83a49712af
commit 3cf37d1251

View File

@ -213,6 +213,17 @@ pshared_clean(void *key, void *val)
_umtx_op(NULL, UMTX_OP_SHM, UMTX_SHM_DESTROY, key, NULL);
}
static void
pshared_destroy(struct pthread *curthread, void *key)
{
void *val;
pshared_wlock(curthread);
val = pshared_remove(key);
pshared_unlock(curthread);
pshared_clean(key, val);
}
void *
__thr_pshared_offpage(void *key, int doalloc)
{
@ -248,13 +259,9 @@ void
__thr_pshared_destroy(void *key)
{
struct pthread *curthread;
void *val;
curthread = _get_curthread();
pshared_wlock(curthread);
val = pshared_remove(key);
pshared_unlock(curthread);
pshared_clean(key, val);
pshared_destroy(curthread, key);
pshared_gc(curthread);
}