VirtualBox

Changeset 42235 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Jul 19, 2012 5:02:41 PM (13 years ago)
Author:
vboxsync
Message:

Runtime/generic/timer-generic.cpp+timerlr-generic.cpp: make timer destruction faster by always signalling the event semaphore, as that's the same as stopping the timer first and then destroying it, only with one event semaphore signalling eliminated

Location:
trunk/src/VBox/Runtime/generic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/generic/timer-generic.cpp

    r39083 r42235  
    55
    66/*
    7  * Copyright (C) 2006-2007 Oracle Corporation
     7 * Copyright (C) 2006-2012 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    159159
    160160    /*
    161      * If the timer is active, we just flag it to self destruct on the next tick.
    162      * If it's suspended we can safely set the destroy flag and signal it.
     161     * If the timer is active, we stop and destruct it in one go, to avoid
     162     * unnecessary waiting for the next tick. If it's suspended we can safely
     163     * set the destroy flag and signal it.
    163164     */
    164165    RTTHREAD Thread = pTimer->Thread;
    165166    if (!pTimer->fSuspended)
    166     {
    167167        ASMAtomicXchgU8(&pTimer->fSuspended, true);
    168         ASMAtomicXchgU8(&pTimer->fDestroyed, true);
    169     }
    170     else
    171     {
    172         ASMAtomicXchgU8(&pTimer->fDestroyed, true);
    173         int rc = RTSemEventSignal(pTimer->Event);
    174         if (rc == VERR_ALREADY_POSTED)
    175             rc = VINF_SUCCESS;
    176         AssertRC(rc);
    177     }
     168    ASMAtomicXchgU8(&pTimer->fDestroyed, true);
     169    int rc = RTSemEventSignal(pTimer->Event);
     170    if (rc == VERR_ALREADY_POSTED)
     171        rc = VINF_SUCCESS;
     172    AssertRC(rc);
    178173
    179174    RTThreadWait(Thread, 250, NULL);
  • trunk/src/VBox/Runtime/generic/timerlr-generic.cpp

    r41774 r42235  
    88
    99/*
    10  * Copyright (C) 2006-2008 Oracle Corporation
     10 * Copyright (C) 2006-2012 Oracle Corporation
    1111 *
    1212 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    154154
    155155    /*
    156      * If the timer is active, we just flag it to self destruct on the next tick.
    157      * If it's suspended we can safely set the destroy flag and signal it.
     156     * If the timer is active, we stop and destruct it in one go, to avoid
     157     * unnecessary waiting for the next tick. If it's suspended we can safely
     158     * set the destroy flag and signal it.
    158159     */
    159160    RTTHREAD hThread = pThis->hThread;
    160161    if (!pThis->fSuspended)
    161     {
    162162        ASMAtomicWriteBool(&pThis->fSuspended, true);
    163         ASMAtomicWriteBool(&pThis->fDestroyed, true);
    164     }
    165     else
    166     {
    167         ASMAtomicWriteBool(&pThis->fDestroyed, true);
    168         int rc = RTSemEventSignal(pThis->hEvent);
    169         if (rc == VERR_ALREADY_POSTED)
    170             rc = VINF_SUCCESS;
    171         AssertRC(rc);
    172     }
    173 
    174     RTThreadWait(hThread, 500, NULL); /* 250 ms was not enough for valgrind! */
     163    ASMAtomicWriteBool(&pThis->fDestroyed, true);
     164    int rc = RTSemEventSignal(pThis->hEvent);
     165    if (rc == VERR_ALREADY_POSTED)
     166        rc = VINF_SUCCESS;
     167    AssertRC(rc);
     168
     169    RTThreadWait(hThread, 250, NULL);
    175170    return VINF_SUCCESS;
    176171}
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