VirtualBox

Changeset 13653 in vbox for trunk/src/VBox/Runtime/r3/posix


Ignore:
Timestamp:
Oct 29, 2008 2:28:27 PM (16 years ago)
Author:
vboxsync
Message:

IPRT: RTThreadPoke for posix.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/posix/thread-posix.cpp

    r8245 r13653  
    6161static void *rtThreadNativeMain(void *pvArgs);
    6262static void rtThreadKeyDestruct(void *pvValue);
    63 
     63static void rtThreadPosixPokeSignal(int iSignal);
    6464
    6565int rtThreadNativeInit(void)
     
    6969     * a threads RTTHREADINT structure.
    7070     */
    71 
    7271    int rc = pthread_key_create(&g_SelfKey, rtThreadKeyDestruct);
    73     if (!rc)
    74         return VINF_SUCCESS;
    75     return VERR_NO_TLS_FOR_SELF;
     72    if (rc)
     73        return VERR_NO_TLS_FOR_SELF;
     74
     75    /*
     76     * Register the dummy signal handler for RTThreadPoke.
     77     */
     78    void (*pfnOld)(int);
     79    pfnOld = signal(SIGUSR2, rtThreadPosixPokeSignal);
     80    Assert(pfnOld == SIG_DFL);
     81    return rc;
    7682}
    7783
     
    9399        pthread_setspecific(g_SelfKey, NULL);
    94100    }
     101}
     102
     103
     104/**
     105 * Dummy signal handler for the poke signal.
     106 *
     107 * @param   iSignal     The signal number.
     108 */
     109static void rtThreadPosixPokeSignal(int iSignal)
     110{
     111    Assert(iSignal == SIGUSR2);
     112    NOREF(iSignal);
    95113}
    96114
     
    277295}
    278296
     297
     298RTDECL(int) RTThreadPoke(RTTHREAD hThread)
     299{
     300    AssertReturn(hThread != RTThreadSelf(), VERR_INVALID_PARAMETER);
     301    PRTTHREADINT pThread = rtThreadGet(hThread);
     302    AssertReturn(pThread, VERR_INVALID_HANDLE);
     303
     304    int rc = pthread_kill((pthread_t)(uintptr_t)pThread->Core.Key, SIGUSR2);
     305
     306    rtThreadRelease(pThread);
     307    return RTErrConvertFromErrno(rc);
     308}
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