QuantumLibrary
Bloomberg::quantum::Configuration Class Reference

#include <quantum_configuration.h>

Public Types

enum  BackoffPolicy : int { BackoffPolicy::Linear, BackoffPolicy::Exponential }
 

Public Member Functions

void setNumCoroutineThreads (int num)
 Set the number of threads running coroutines. More...
 
void setNumIoThreads (int num)
 Set the number of threads running IO tasks. More...
 
void setPinCoroutineThreadsToCores (bool value)
 Indicate if coroutine threads should be pinned to a core. More...
 
void setLoadBalanceSharedIoQueues (bool value)
 Load balancee the shared IO queues. More...
 
void setLoadBalancePollIntervalMs (std::chrono::milliseconds interval)
 Set the interval between IO thread polls. More...
 
void setLoadBalancePollIntervalBackoffPolicy (BackoffPolicy policy)
 Set a backoff policy for the shared queue polling interval. More...
 
void setLoadBalancePollIntervalNumBackoffs (size_t numBackoffs)
 Set the number of backoffs. More...
 
void setCoroQueueIdRangeForAny (const std::pair< int, int > &coroQueueIdRangeForAny)
 Sets the range of coroutine queueIds covered by IQueue::QueueId::Any when using Dispatcher::post. More...
 
int getNumCoroutineThreads () const
 Get the number of coroutine threads. More...
 
int getNumIoThreads () const
 Get the number of IO threads. More...
 
bool getPinCoroutineThreadsToCores () const
 Check to see if coroutine threads are pinned to cores or not. More...
 
bool getLoadBalanceSharedIoQueues () const
 Check if IO shared queues are load balanced or not. More...
 
std::chrono::milliseconds getLoadBalancePollIntervalMs () const
 Get load balance shared queue poll interval. More...
 
BackoffPolicy getLoadBalancePollIntervalBackoffPolicy () const
 Get the backoff policy in load balance mode. More...
 
size_t getLoadBalancePollIntervalNumBackoffs () const
 Get the number of backoffs used. More...
 
const std::pair< int, int > & getCoroQueueIdRangeForAny () const
 Gets the range [minQueueId, maxQueueId] of coroutine queueIds covered by IQueue::QueueId::Any by the Dispatcher. More...
 

Static Public Member Functions

static const std::string & getJsonSchema ()
 Get the JSON schema corresponding to this configuration object. More...
 
static const std::string & getJsonSchemaUri ()
 Get the schema URI used to resolve remote JSON references '$ref'. More...
 

Member Enumeration Documentation

◆ BackoffPolicy

Enumerator
Linear 

Linear backoff.

Exponential 

Member Function Documentation

◆ getCoroQueueIdRangeForAny()

const std::pair<int, int>& Bloomberg::quantum::Configuration::getCoroQueueIdRangeForAny ( ) const

Gets the range [minQueueId, maxQueueId] of coroutine queueIds covered by IQueue::QueueId::Any by the Dispatcher.

Returns
queueIdRange The range of queueIds that IQueue::QueueId::Any covers

◆ getJsonSchema()

static const std::string& Bloomberg::quantum::Configuration::getJsonSchema ( )
static

Get the JSON schema corresponding to this configuration object.

Returns
The draft-04 compatible schema.

◆ getJsonSchemaUri()

static const std::string& Bloomberg::quantum::Configuration::getJsonSchemaUri ( )
static

Get the schema URI used to resolve remote JSON references '$ref'.

Returns
The URI.

◆ getLoadBalancePollIntervalBackoffPolicy()

BackoffPolicy Bloomberg::quantum::Configuration::getLoadBalancePollIntervalBackoffPolicy ( ) const

Get the backoff policy in load balance mode.

Returns
The backoff policy used.

◆ getLoadBalancePollIntervalMs()

std::chrono::milliseconds Bloomberg::quantum::Configuration::getLoadBalancePollIntervalMs ( ) const

Get load balance shared queue poll interval.

Returns
The number of milliseconds.

◆ getLoadBalancePollIntervalNumBackoffs()

size_t Bloomberg::quantum::Configuration::getLoadBalancePollIntervalNumBackoffs ( ) const

Get the number of backoffs used.

Returns
The number of backoffs.

◆ getLoadBalanceSharedIoQueues()

bool Bloomberg::quantum::Configuration::getLoadBalanceSharedIoQueues ( ) const

Check if IO shared queues are load balanced or not.

Returns
True or False.

◆ getNumCoroutineThreads()

int Bloomberg::quantum::Configuration::getNumCoroutineThreads ( ) const

Get the number of coroutine threads.

Returns
The number of threads.

◆ getNumIoThreads()

int Bloomberg::quantum::Configuration::getNumIoThreads ( ) const

Get the number of IO threads.

Returns
The number of threads.

◆ getPinCoroutineThreadsToCores()

bool Bloomberg::quantum::Configuration::getPinCoroutineThreadsToCores ( ) const

Check to see if coroutine threads are pinned to cores or not.

Returns
True or False.

◆ setCoroQueueIdRangeForAny()

void Bloomberg::quantum::Configuration::setCoroQueueIdRangeForAny ( const std::pair< int, int > &  coroQueueIdRangeForAny)

Sets the range of coroutine queueIds covered by IQueue::QueueId::Any when using Dispatcher::post.

Parameters
[in]coroQueueIdRangeForAnyThe range [minQueueId, maxQueueId] of queueIds that IQueue::QueueId::Any will cover.
Remarks
if the provided range is empty or invalid, then the default range of std::pair<int, int>(0, getNumCoroutineThreads()-1) will be used

◆ setLoadBalancePollIntervalBackoffPolicy()

void Bloomberg::quantum::Configuration::setLoadBalancePollIntervalBackoffPolicy ( BackoffPolicy  policy)

Set a backoff policy for the shared queue polling interval.

Parameters
[in]policyThe backoff policy to use. Default is 'Linear'.

◆ setLoadBalancePollIntervalMs()

void Bloomberg::quantum::Configuration::setLoadBalancePollIntervalMs ( std::chrono::milliseconds  interval)

Set the interval between IO thread polls.

Parameters
[in]intervalInterval in milliseconds. Default is 100ms.
Note
Setting this to a higher value means it may take longer to react to the first IO task posted, and vice-versa if the interval is lower.

◆ setLoadBalancePollIntervalNumBackoffs()

void Bloomberg::quantum::Configuration::setLoadBalancePollIntervalNumBackoffs ( size_t  numBackoffs)

Set the number of backoffs.

Parameters
[in]numBackoffsThe number of backoff increments. Default is 0. When the number of backoffs is reached, the poll interval remains unchanged thereafter.

◆ setLoadBalanceSharedIoQueues()

void Bloomberg::quantum::Configuration::setLoadBalanceSharedIoQueues ( bool  value)

Load balancee the shared IO queues.

Parameters
[in]valueIf set to true, posting to the 'any' IO queue will result in the load being spread among N queues. This mode can provide higher throughput if dealing with high task loads. Default is false.
Note
To achieve higher performance, the threads run in polling mode which increases CPU usage even when idle.

◆ setNumCoroutineThreads()

void Bloomberg::quantum::Configuration::setNumCoroutineThreads ( int  num)

Set the number of threads running coroutines.

Parameters
[in]numThe number of threads. Set to -1 to have one coroutine thread per core. Default is -1.

◆ setNumIoThreads()

void Bloomberg::quantum::Configuration::setNumIoThreads ( int  num)

Set the number of threads running IO tasks.

Parameters
[in]numThe number of threads. Default is 5.

◆ setPinCoroutineThreadsToCores()

void Bloomberg::quantum::Configuration::setPinCoroutineThreadsToCores ( bool  value)

Indicate if coroutine threads should be pinned to a core.

Parameters
[in]valueTrue or False. Default is False.
Note
For best performance, the number of coroutine threads should be <= the number of cores in the system.