From: Romano Paolo Tenca <rotenca@telvia.it>
To: pthreads-win32@sourceware.org
Subject: Proposal: non standard user data hook
Date: Mon, 28 May 2007 19:59:00 -0000 [thread overview]
Message-ID: <46594A33.5000901@telvia.it> (raw)
I have seen (under windows) many cases where user must associate some
data to new thread to be used from another thread. Usually pthread id is
registered in a user array/list of structures with the data needed for
future access. When the user need that data he will search the array for
the pthread id: this means allocation, search, destroy, mutex and a lot
of complexity, bugs and race conditions.
My proposal is a np set of functions to set and get user data:
void pthread_userdataset_np(ptrhead_t id, void * userdata)
void * pthread_userdataget_np(ptrhead_t id)
pthread_userdataget_np return NULL if pthread_userdataset_np() was never
called or the thread has already been destroyed.
Implementation is very simple: add an user slot to ptw32_thread_t structure.
That slot is totally ignored by pthread functions, only when the
ptw32_thread_t is destroyed the pointer is set to NULL.
--
Romano Paolo Tenca
reply other threads:[~2007-05-27 9:07 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=46594A33.5000901@telvia.it \
--to=rotenca@telvia.it \
--cc=pthreads-win32@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).