VirtualBox

Changeset 36596 in vbox for trunk/src/VBox/Runtime/common


Ignore:
Timestamp:
Apr 6, 2011 7:45:34 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
71041
Message:

iprt/thread.h: Added RTThreadIsInitialized, RTThreadIsSelfKnown and RTThreadIsSelfAlive.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/misc/thread.cpp

    r36555 r36596  
    8484static RTSPINLOCK       g_ThreadSpinlock = NIL_RTSPINLOCK;
    8585#endif
     86/** Indicates whether we've been initialized or not. */
     87static bool             g_frtThreadInitialized;
    8688
    8789
     
    146148                rc = rtSchedNativeCalcDefaultPriority(RTTHREADTYPE_DEFAULT);
    147149            if (RT_SUCCESS(rc))
     150            {
     151                g_frtThreadInitialized = true;
    148152                return VINF_SUCCESS;
     153            }
    149154
    150155            /* failed, clear out */
     
    165170        rc = rtThreadNativeInit();
    166171        if (RT_SUCCESS(rc))
     172        {
     173            g_frtThreadInitialized = true;
    167174            return VINF_SUCCESS;
     175        }
    168176
    169177        /* failed, clear out */
     
    9941002
    9951003
     1004RTDECL(bool) RTThreadIsSelfAlive(void)
     1005{
     1006    if (g_frtThreadInitialized)
     1007    {
     1008        RTTHREAD hSelf = RTThreadSelf();
     1009        if (hSelf != NIL_RTTHREAD)
     1010        {
     1011            /*
     1012             * Inspect the thread state.  ASSUMES thread state order.
     1013             */
     1014            RTTHREADSTATE enmState = rtThreadGetState(hSelf);
     1015            if (   enmState >= RTTHREADSTATE_RUNNING
     1016                && enmState <= RTTHREADSTATE_END)
     1017                return true;
     1018        }
     1019    }
     1020    return false;
     1021}
     1022RT_EXPORT_SYMBOL(RTThreadIsSelfAlive);
     1023
     1024
     1025RTDECL(bool) RTThreadIsSelfKnown(void)
     1026{
     1027    if (g_frtThreadInitialized)
     1028    {
     1029        RTTHREAD hSelf = RTThreadSelf();
     1030        if (hSelf != NIL_RTTHREAD)
     1031            return true;
     1032    }
     1033    return false;
     1034}
     1035RT_EXPORT_SYMBOL(RTThreadIsSelfKnown);
     1036
     1037
     1038RTDECL(bool) RTThreadIsInitialized(void)
     1039{
     1040    return g_frtThreadInitialized;
     1041}
     1042RT_EXPORT_SYMBOL(RTThreadIsInitialized);
     1043
     1044
    9961045/**
    9971046 * Signal the user event.
Note: See TracChangeset for help on using the changeset viewer.

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