BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslmt_configuration

Detailed Description

Outline

Purpose

Provide utilities to allow configuration of values for BCE.

Classes

See also
bslmt_threadattributes, bslmt_threadutil

Description

This component defines a utility struct, bslmt::Configuration, that is a name space for pure functions used for providing access to, and configuring, default values for BCE-relevant parameters. The bslmt::Configuration utility currently provides static methods to access and modify the BCE library's default stack size, as well as functions that access the platform's native default stack size and guard size. The BDE default stack size is initially configured to bslmt::ThreadAttributes::BSLMT_UNSET_STACK_SIZE, in which case thread creation is to use the native default thread stack size.

Usage

This section illustrates intended use of this component.

Example 1: Demonstrate Accessing & Modifying the Default Thread Stack Size {#bslmt_configuration-example-1-demonstrate-accessing-&-modifying-the-default-thread-stack-size}

In this example we demonstrate how to access both the platform's native and BDE configured default stack sizes, and then to set the default stack size used by BDE. Note that the value returned by defaultThreadStackSize may be adjusted from that provided by the underlying operating system to reflect the actual amount of stack memory available to a created thread. Note that operations creating a thread should perform a similar inverse adjustment when configuring the new thread's stack size (see bslmt_threadutil ).

First, we examine the platform's native thread stack size:

const int nativeDefault =
assert(nativeDefault > 0);
static int nativeDefaultThreadStackSize()

Then, we verify that defaultThreadStackSize is unset.

Next, we define newDefaultStackSize to some size other than the platform's native default stack size:

const int newDefaultStackSize = nativeDefault * 2;

Now, we set the default size for BCE to the new size:

static void setDefaultThreadStackSize(int numBytes)

Finally, we verify that BCE's default thread stack size has been set to the value we specified:

newDefaultStackSize);