VirtualBox

Changeset 90969 in vbox


Ignore:
Timestamp:
Aug 27, 2021 10:12:22 PM (3 years ago)
Author:
vboxsync
Message:

IPRT/log: Defined the multibuffer flush protocol. bugref:10086

Location:
trunk
Files:
2 edited

Legend:

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

    r90865 r90969  
    197197 * Custom buffer flushing function.
    198198 *
    199  * @retval  true if flushed.
    200  * @retval  false if flushing pending on other thread and the logger should
    201  *          switch to the next buffer.  The other thread will call
    202  *          RTLogFlushDone when finished.
     199 * @retval  true if flushed and the buffer can be reused.
     200 * @retval  false for switching to the next buffer because an async flush of
     201 *          @a pBufDesc is still pending.  The implementation is responsible for
     202 *          only returning when the next buffer is ready for reuse, the generic
     203 *          logger code has no facility to make sure of this.
     204 *
    203205 * @param   pLogger     Pointer to the logger instance which is to be flushed.
    204206 * @param   pBufDesc    The descriptor of the buffer to be flushed.
     
    288290
    289291/** RTLOGBUFFERDESC::u32Magic value. (Avram Noam Chomsky) */
    290 # define RTLOGBUFFERDESC_MAGIC   UINT32_C(0x19281207)
     292#define RTLOGBUFFERDESC_MAGIC   UINT32_C(0x19281207)
    291293
    292294/**
     
    321323
    322324/** RTLOGGER::u32Magic value. (John Rogers Searle) */
    323 #define RTLOGGER_MAGIC      UINT32_C(0x19320731)
     325#define RTLOGGER_MAGIC          UINT32_C(0x19320731)
    324326
    325327/**
  • trunk/src/VBox/Runtime/common/log/log.cpp

    r90866 r90969  
    31073107static void rtlogFlush(PRTLOGGERINTERNAL pLoggerInt, bool fNeedSpace)
    31083108{
    3109     PRTLOGBUFFERDESC const pBufDesc   = pLoggerInt->pBufDesc;
    3110     uint32_t               cchToFlush = pBufDesc->offBuf;
    3111     char * const           pchToFlush = pBufDesc->pchBuf;
    3112     uint32_t const         cbBuf      = pBufDesc->cbBuf;
     3109    PRTLOGBUFFERDESC   pBufDesc   = pLoggerInt->pBufDesc;
     3110    uint32_t            cchToFlush = pBufDesc->offBuf;
     3111    char * const        pchToFlush = pBufDesc->pchBuf;
     3112    uint32_t const      cbBuf      = pBufDesc->cbBuf;
    31133113    Assert(pBufDesc->u32Magic == RTLOGBUFFERDESC_MAGIC);
    31143114
     
    31803180        if (pLoggerInt->pfnFlush)
    31813181        {
    3182             /** @todo implement asynchronous buffer switching protocol. */
    3183             bool fDone;
     3182            /*
     3183             * We have a custom flush callback.  Before calling it we must make
     3184             * sure the aux descriptor is up to date.  When we get back, we may
     3185             * need to switch to the next buffer if the current is being flushed
     3186             * asynchronously.  This of course requires there to be more than one
     3187             * buffer.  (The custom flush callback is responsible for making sure
     3188             * the next buffer isn't being flushed before returning.)
     3189             */
    31843190            if (pBufDesc->pAux)
    31853191                pBufDesc->pAux->offBuf = cchToFlush;
    3186             fDone = pLoggerInt->pfnFlush(&pLoggerInt->Core, pBufDesc);
    3187             Assert(fDone == true); RT_NOREF(fDone);
    3188         }
    3189 
    3190         /* empty the buffer. */
     3192            if (!pLoggerInt->pfnFlush(&pLoggerInt->Core, pBufDesc))
     3193            {
     3194                /* advance to the next buffer */
     3195                Assert(pLoggerInt->cBufDescs > 1);
     3196                size_t idxBufDesc = pBufDesc - pLoggerInt->paBufDescs;
     3197                Assert(idxBufDesc < pLoggerInt->cBufDescs);
     3198                idxBufDesc = (idxBufDesc + 1) % pLoggerInt->cBufDescs;
     3199                pLoggerInt->idxBufDesc = (uint8_t)idxBufDesc;
     3200                pLoggerInt->pBufDesc   = pBufDesc = &pLoggerInt->paBufDescs[idxBufDesc];
     3201            }
     3202        }
     3203
     3204        /* Empty the buffer. */
    31913205        pBufDesc->offBuf = 0;
    31923206        if (pBufDesc->pAux)
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