From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7314 invoked by alias); 27 May 2007 09:07:06 -0000 Received: (qmail 7075 invoked by uid 22791); 27 May 2007 09:07:05 -0000 X-Spam-Check-By: sourceware.org Received: from mail.telvia.it (HELO efesto.telvia.it) (213.155.209.57) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 27 May 2007 09:07:02 +0000 Received: from [213.155.203.130] (unverified [213.155.203.130]) by efesto.telvia.it (Vircom SMTPRS 5.3.228) with ESMTP id for ; Sun, 27 May 2007 11:06:46 +0200 Message-ID: <46594A33.5000901@telvia.it> Date: Mon, 28 May 2007 19:59:00 -0000 From: Romano Paolo Tenca User-Agent: Thunderbird 2.0.0.0 (Windows/20070326) MIME-Version: 1.0 To: pthreads-win32@sourceware.org Subject: Proposal: non standard user data hook Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact pthreads-win32-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: pthreads-win32-owner@sourceware.org X-SW-Source: 2007/txt/msg00029.txt.bz2 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