This is the mail archive of the pthreads-win32@sourceware.org mailing list for the pthreas-win32 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Proposal: non standard user data hook



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]