VirtualBox

Changeset 25295 in vbox for trunk/include/iprt


Ignore:
Timestamp:
Dec 10, 2009 1:12:41 PM (15 years ago)
Author:
vboxsync
Message:

iprt/thread.h: more docs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/thread.h

    r25294 r25295  
    666666
    667667/**
    668  * Allocates a TLS entry (index). Before using an item of TLS, this must be called
    669  * once for the process; the RTTLS value returned is then typically stored in a global
    670  * or static variable. See RTTlsGet() for example code.
     668 * Allocates a TLS entry (index).
     669 *
     670 * Example code:
     671 * @code
     672    RTTLS g_iTls = NIL_RTTLS;
     673
     674    ...
     675
     676    // once for the process, allocate the TLS index
     677    if (g_iTls == NIL_RTTLS)
     678         g_iTls = RTTlsAlloc();
     679
     680    // set the thread-local value.
     681    RTTlsSet(g_iTls, pMyData);
     682
     683    ...
     684
     685    // get the thread-local value
     686    PMYDATA pMyData = (PMYDATA)RTTlsGet(g_iTls);
     687
     688   @endcode
    671689 *
    672690 * @returns the index of the allocated TLS entry.
     
    676694
    677695/**
    678  * Allocates a TLS entry (index, with status code).
     696 * Variant of RTTlsAlloc that returns a status code.
    679697 *
    680698 * @returns IPRT status code.
     
    700718/**
    701719 * Get the (thread-local) value stored in a TLS entry.
    702  * If RTTlsSet() has not yet been called, returns NULL.
    703  *
    704  * Example code:
    705  * <code>
    706  * RTTLS g_globalTLSIndex = NIL_RTTLS;
    707  *
    708  * ...
    709  *
    710  * // once for the process, allocate the TLS index
    711  * if (g_globalTLSIndex == NIL_RTTLS)
    712  *      g_globalTLSIndex = RTTlsAlloc();
    713  *
    714  * // get the thread-local value
    715  * void* pv = RTTlsGet(g_globalTLSIndex);
    716  *
    717  * </code>
    718720 *
    719721 * @returns value in given TLS entry.
    720  * @returns NULL on failure.
     722 * @retval  NULL if RTTlsSet() has not yet been called on this thread, or if the
     723 *          TLS index is invalid.
     724 *
    721725 * @param   iTls        The index of the TLS entry.
    722726 */
     
    728732 * @returns IPRT status code.
    729733 * @param   iTls        The index of the TLS entry.
    730  * @param   ppvValue    Where to store the value.
     734 * @param   ppvValue    Where to store the value.  The value will be NULL if
     735 *                      RTTlsSet has not yet been called on this thread.
    731736 */
    732737RTR3DECL(int) RTTlsGetEx(RTTLS iTls, void **ppvValue);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette