Ignore:
Timestamp:
May 20, 2001, 5:38:55 PM (24 years ago)
Author:
umoeller
Message:

misc updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/threads.c

    r52 r70  
    130130    if (pti)
    131131    {
    132         if (pti->pfRunning)
    133             // set "running" flag
    134             *(pti->pfRunning) = TRUE;
    135 
    136132        if (pti->flFlags & THRF_WAIT)
    137133            // "Wait" flag set: thrCreate is then
     
    174170        }
    175171
    176         // for non-transient threads: set exit flags
     172        // set exit flags
    177173        // V0.9.7 (2000-12-20) [umoeller]
    178174        pti->fExitComplete = TRUE;
    179175        pti->tid = NULLHANDLE;
    180176
    181         if (pti->pfRunning)
     177        if (pti->ptidRunning)
    182178            // clear "running" flag
    183             *(pti->pfRunning) = FALSE;
     179            *(pti->ptidRunning) = 0;
    184180
    185181        // (2000-12-18) [lafaix] clean up pti if thread is transient.
     
    213209 *      The thread's ptiMyself is then a pointer to the
    214210 *      THREADINFO structure passed to this function.
    215  *      ulData may be obtained like this:
     211 *      In your thread function, ulData may be obtained like this:
    216212 *
    217213 +          ULONG ulData = ptiMyself->ulData;
    218214 *
    219  *      The THREADINFO structure passed to this function must
    220  *      be accessible all the time while the thread is running
    221  *      because the thr* functions will use it for maintenance.
    222  *
    223  *      This function does NOT check whether a thread is
    224  *      already running in *pti. Do not use the same THREADINFO
    225  *      for several threads.
    226  *
    227  *      If you do not want to manage the structure yourself,
    228  *      you can pass the THRF_TRANSIENT flag (see below).
    229  *
    230  *      thrCreate does not call your thread func directly,
     215 *      thrCreate does not start your thread func directly,
    231216 *      but only through the thr_fntGeneric wrapper to
    232217 *      provide additional functionality. As a consequence,
     
    235220 *      (cleanup) in thr_fntGeneric. Instead, just fall out of
    236221 *      your thread function, or return().
     222 *
     223 *      The THREADINFO structure passed to this function must
     224 *      be accessible all the time while the thread is running
     225 *      because the thr* functions will use it for maintenance.
     226 *      This function does NOT check whether a thread is
     227 *      already running in *pti. Do not use the same THREADINFO
     228 *      for several threads.
     229 *
     230 *      If you do not want to manage the structure yourself,
     231 *      you can pass the THRF_TRANSIENT flag (see below).
     232 *
     233 *      ptidRunning is an optional parameter and can be NULL.
     234 *      If non-null, it must point to a ULONG which will contain
     235 *      the thread's TID while the thread is still running.
     236 *      Once the thread exits, the ULONG will automatically
     237 *      be set to zero; this is useful for a quick check whether
     238 *      the thread is currently busy.
     239 *
     240 *      Note: ptidRunning is only reliable if you set the
     241 *      THRF_WAIT or THRF_WAIT_EXPLICIT flags.
    237242 *
    238243 *      flFlags can be any combination of the following:
     
    252257 *
    253258 *      -- THRF_WAIT_EXPLICIT: like THRF_WAIT, but in this case,
    254  *         your thread function must post THREADINFO.hevRunning
     259 *         your thread function _must_ post THREADINFO.hevRunning
    255260 *         yourself (thr_fntGeneric will not automatically
    256261 *         post it). Useful for waiting until your own thread
     
    282287 *@@changed V0.9.9 (2001-03-07) [umoeller]: added pcszThreadName
    283288 *@@changed V0.9.9 (2001-03-14) [umoeller]: added THRF_WAIT_EXPLICIT
     289 *@@changed V0.9.12 (2001-05-20) [umoeller]: changed pfRunning to ptidRunning
    284290 */
    285291
    286292ULONG thrCreate(PTHREADINFO pti,     // out: THREADINFO data
    287293                PTHREADFUNC pfn,     // in: _Optlink thread function
    288                 PBOOL pfRunning,     // out: variable set to TRUE while thread is running;
     294                PULONG ptidRunning,  // out: variable set to TID while thread is running;
    289295                                     // ptr can be NULL
    290296                const char *pcszThreadName, // in: thread name (for identification)
     
    307313        pti->cbStruct = sizeof(THREADINFO);
    308314        pti->pThreadFunc = (PVOID)pfn;
    309         pti->pfRunning = pfRunning;
     315        pti->ptidRunning = ptidRunning;
    310316        pti->pcszThreadName = pcszThreadName; // V0.9.9 (2001-03-07) [umoeller]
    311317        pti->flFlags = flFlags;
     
    336342                                    pti);   // parameter passed to thread
    337343            ulrc = pti->tid;
     344
     345            if (pti->ptidRunning)
     346                // set "running" flag // V0.9.12 (2001-05-20) [umoeller]
     347                *(pti->ptidRunning) = pti->tid;
    338348
    339349            if (ulrc)
Note: See TracChangeset for help on using the changeset viewer.