reqpool.cpp revision fe14fe6d46ce87a9b25cbdacb3a20b1f87bf34c7
/* $Id$ */
/** @file
* IPRT - Request Pool.
*/
/*
* Copyright (C) 2006-2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <iprt/critsect.h>
#include <iprt/semaphore.h>
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
typedef struct RTREQPOOLTHREAD
{
/** Node in the RTREQPOOLINT::IdleThreads list. */
/** Node in the RTREQPOOLINT::WorkerThreads list. */
/** The submit timestamp of the pending request. */
/** When this CPU went idle the last time. */
/** The number of requests processed by this thread. */
/** Total time the requests processed by this thread took to process. */
/** Total time the requests processed by this thread had to wait in
* the queue before being scheduled. */
/** The CPU this was scheduled last time we checked. */
/** The thread handle. */
/** The submitter will put an incoming request here when scheduling an idle
* thread. */
/** The request the thread is currently processing. */
PRTREQINT volatile pPendingReq;
typedef struct RTREQPOOLINT
{
/** Magic value (RTREQPOOL_MAGIC). */
/** The current number of worker threads. */
/** The maximum number of worker threads. */
/** The number of threads which should be spawned before throttling kicks
* in. */
/** The minimum number of worker threads. */
/** The number of milliseconds a thread needs to be idle before it is
* considered for retirement. */
/** Statistics: The total number of threads created. */
/** Statistics: The timestamp when the last thread was created. */
/** Linked list of worker threads. */
/** Critical section serializing access to members of this structure. */
/** Reference counter. */
/** Linked list of idle threads. */
} RTREQPOOLINT;
/** Pointer to a request thread pool instance. */
typedef RTREQPOOLINT *PRTREQPOOLINT;