Ignore:
Timestamp:
Apr 29, 2004, 5:35:22 AM (21 years ago)
Author:
bird
Message:

Added thread termination callback functionality.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/include/InnoTekLIBC/thread.h

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r1399 r1400  
    141141
    142142
     143/**
     144 * Thread Termination Callback Registration Record. (cool name, right)
     145 * For use with __libc_ThreadRegisterTermCallback().
     146 */
     147typedef struct __libc_ThreadTermCbRegRec
     148{
     149    /** This member must be initialized to NULL. */
     150    struct __libc_ThreadTermCbRegRec   *pNext;
     151    /** Flags field reserved for future use.
     152     * Must be initalized to ZERO.  */
     153    unsigned                            fFlags;
     154    /**
     155     * The callback function.
     156     *
     157     * @param pRegRec   Registration record which the callback was registered with.
     158     * @param fFlags    Reserved for future use. Will always be zero when fFlags
     159     *                  in the RegRec is zero.
     160     */
     161    void                              (*pfnCallback)(struct __libc_ThreadTermCbRegRec *pRegRec, unsigned fFlags);
     162} __LIBC_THREADTERMCBREGREC, *__LIBC_PTHREADTERMCBREGREC;
     163
     164
    143165/*******************************************************************************
    144166*   Global Variables                                                           *
     
    223245
    224246
     247/**
     248 * Register a thread destruction callback.
     249 *
     250 * This will be called when one thread is terminating normally, i.e. calling
     251 * _endthread() or returning from it's thread function.
     252 * When LIBC implements pthreads basics any new non-abnormal thread exit will
     253 * cause a callback too.
     254 *
     255 * @param   pRegRec     Pointer to thread registration record.
     256 *                      This must be initialized as described in the documation of
     257 *                      the structure. After calling this API the memory must not
     258 *                      be touched or freed by the application. It is not possible
     259 *                      to unregister a callback at present.
     260 *
     261 * @remark  We might wanna extend the API at a later point for calling back
     262 *          at abnormal termination and such. Such extensions will be done
     263 *          using the fFlags member of __LIBC_THREADTERMCBREGREC and the fFlags
     264 *          parameter to the callback.
     265 */
     266int     __libc_ThreadRegisterTermCallback(__LIBC_PTHREADTERMCBREGREC pRegRec);
     267
     268/**
     269 * Internal API which is called by a thread exit to work the registered callbacks.
     270 *
     271 * Not called for thread 1.
     272 *
     273 * @param   fFlags  Reserved for termination reasons.
     274 *                  Zero means normal exit, no other codes have been defined.
     275 */
     276void    __libc_threadTermination(unsigned fFlags);
     277
     278
    225279/** @group InnoTek LIBC Thread Local Storage
    226280 * @{
     
    263317int     __libc_TLSSet(int iIndex, void *pvValue);
    264318
     319/**
     320 * Register a thread termination destructor for an TLS entry.
     321 *
     322 * The destructor function will be called when a thread terminates
     323 * in a normal fashion and the TLS entry iTLSIndex of that thread is
     324 * not NULL.
     325 *
     326 * There will be no callbacks in thread 1.
     327 *
     328 * @returns 0 on succces.
     329 * @returns -1 on failure. errno set.
     330 * @param   iTLSIndex       Value returned by __libc_TLSAlloc().
     331 * @param   pfnDestructor   Callback function. Use NULL to unregister a previously
     332 *                          registered destructor.
     333 *
     334 *                          It's pvValue argument is the non-zero value in the
     335 *                          TLS entry for the thread it's called on.
     336 *
     337 *                          It's fFlags argument is reserved for future use, it will
     338 *                          always be zero when the fFlags parameter to this API is zero.
     339 *
     340 * @param   fFlags          Flags reserved for future use. At the moment
     341 *                          only ZERO is allowed.
     342 *
     343 * @remark  The application is not allowed to call __libc_TLSFree() for iIndex when calling
     344 *          this function. The result from doing that is undefined.
     345 */
     346int     __libc_TLSDestructor(int iIndex, void (*pfnDestructor)(void *pvValue, unsigned fFlags), unsigned fFlags);
     347
    265348/** @} */
     349
    266350__END_DECLS
    267351
Note: See TracChangeset for help on using the changeset viewer.