BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslmt::ThreadAttributes Class Reference

#include <bslmt_threadattributes.h>

Public Types

enum  DetachedState {
  e_CREATE_JOINABLE = 0 , e_CREATE_DETACHED = 1 , BCEMT_CREATE_JOINABLE = e_CREATE_JOINABLE , BCEMT_CREATE_DETACHED = e_CREATE_DETACHED ,
  CREATE_JOINABLE = e_CREATE_JOINABLE , CREATE_DETACHED = e_CREATE_DETACHED
}
 
enum  SchedulingPolicy {
  e_SCHED_OTHER = 0 , e_SCHED_FIFO = 1 , e_SCHED_RR = 2 , e_SCHED_DEFAULT = 3 ,
  BCEMT_SCHED_OTHER = e_SCHED_OTHER , BCEMT_SCHED_FIFO = e_SCHED_FIFO , BCEMT_SCHED_RR = e_SCHED_RR , BCEMT_SCHED_DEFAULT = e_SCHED_DEFAULT
}
 
enum  {
  e_UNSET_STACK_SIZE = -1 , e_UNSET_GUARD_SIZE = -1 , e_UNSET_PRIORITY = INT_MIN , e_SCHED_MIN = e_SCHED_OTHER ,
  e_SCHED_MAX = e_SCHED_DEFAULT , BCEMT_UNSET_STACK_SIZE = e_UNSET_STACK_SIZE , BCEMT_UNSET_GUARD_SIZE = e_UNSET_GUARD_SIZE , BCEMT_UNSET_PRIORITY = e_UNSET_PRIORITY ,
  BCEMT_SCHED_MIN = e_SCHED_MIN , BCEMT_SCHED_MAX = e_SCHED_MAX
}
 

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (ThreadAttributes, bslma::UsesBslmaAllocator)
 
 ThreadAttributes ()
 
 ThreadAttributes (bslma::Allocator *basicAllocator)
 
 ThreadAttributes (const ThreadAttributes &original, bslma::Allocator *basicAllocator=0)
 
ThreadAttributesoperator= (const ThreadAttributes &rhs)
 
ThreadAttributessetDetachedState (DetachedState value)
 
ThreadAttributessetGuardSize (int value)
 
ThreadAttributessetInheritSchedule (bool value)
 
ThreadAttributessetSchedulingPolicy (SchedulingPolicy value)
 
ThreadAttributessetSchedulingPriority (int value)
 
ThreadAttributessetStackSize (int value)
 
ThreadAttributessetThreadName (const bslstl::StringRef &value)
 
DetachedState detachedState () const
 
int guardSize () const
 
bool inheritSchedule () const
 
bsl::ostream & print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
 
SchedulingPolicy schedulingPolicy () const
 
int schedulingPriority () const
 
int stackSize () const
 
bslstl::StringRef threadName () const
 
bslma::Allocatorallocator () const
 Return the allocator used by this object to supply memory.
 

Detailed Description

This simply constrained (value-semantic) attribute class characterizes a collection of thread attribute values. See the Attributes section for information on the class attributes.

This class:

  • supports a complete set of value semantic operations
    • except for bdex serialization
  • is exception-neutral
  • is alias-safe
  • is const thread-safe For terminology see bsldoc_glossary .

See bslmt_threadattributes

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

The following constants indicate that the stackSize, guardSize, and schedulingPriority attributes, respectively, are unspecified and the thread creation routine is use platform-specific defaults. These attributes are initialized to these values when a thread attributes object is default constructed.

Enumerator
e_UNSET_STACK_SIZE 
e_UNSET_GUARD_SIZE 
e_UNSET_PRIORITY 
e_SCHED_MIN 
e_SCHED_MAX 
BCEMT_UNSET_STACK_SIZE 
BCEMT_UNSET_GUARD_SIZE 
BCEMT_UNSET_PRIORITY 
BCEMT_SCHED_MIN 
BCEMT_SCHED_MAX 

◆ DetachedState

This enumeration provides two values used to distinguish among a joinable thread and a non-joinable (detached) thread.

Enumerator
e_CREATE_JOINABLE 
e_CREATE_DETACHED 
BCEMT_CREATE_JOINABLE 
BCEMT_CREATE_DETACHED 
CREATE_JOINABLE 
CREATE_DETACHED 

◆ SchedulingPolicy

Enumerator
e_SCHED_OTHER 
e_SCHED_FIFO 
e_SCHED_RR 
e_SCHED_DEFAULT 
BCEMT_SCHED_OTHER 
BCEMT_SCHED_FIFO 
BCEMT_SCHED_RR 
BCEMT_SCHED_DEFAULT 

Constructor & Destructor Documentation

◆ ThreadAttributes() [1/3]

bslmt::ThreadAttributes::ThreadAttributes ( )

◆ ThreadAttributes() [2/3]

bslmt::ThreadAttributes::ThreadAttributes ( bslma::Allocator basicAllocator)
explicit

Create a ThreadAttributes object having the (default) attribute values:

◆ ThreadAttributes() [3/3]

bslmt::ThreadAttributes::ThreadAttributes ( const ThreadAttributes original,
bslma::Allocator basicAllocator = 0 
)

Create a ThreadAttributes object having the same value as the specified original object. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

Member Function Documentation

◆ allocator()

bslma::Allocator * bslmt::ThreadAttributes::allocator ( ) const
inline

◆ BSLMF_NESTED_TRAIT_DECLARATION()

bslmt::ThreadAttributes::BSLMF_NESTED_TRAIT_DECLARATION ( ThreadAttributes  ,
bslma::UsesBslmaAllocator   
)

◆ detachedState()

ThreadAttributes::DetachedState bslmt::ThreadAttributes::detachedState ( ) const
inline

Return the value of the detachedState attribute of this object. A value of e_CREATE_JOINABLE indicates that a thread must be joined after it terminates to clean up its resources; a value of e_CREATE_DETACHED (the only other legal value) indicates that the resources will be cleaned up automatically upon thread termination, and that the thread must not be joined.

◆ guardSize()

int bslmt::ThreadAttributes::guardSize ( ) const
inline

Return the value of the guardSize attribute of this object. The value e_UNSET_GUARD_SIZE == guardSize is intended to indicate that the default value as defined by the platform (which is typically the size of one or two pages) should be obtained from bslmt_configuration and used.

◆ inheritSchedule()

bool bslmt::ThreadAttributes::inheritSchedule ( ) const
inline

Return the value of the inheritSchedule attribute of this object. A value of false for the inherit schedule attribute indicates that a thread should not inherit the scheduling policy and priority of the thread that created it and instead should use the respective values supplied by this object; whereas a value of true indicates that the thread should inherit these attributes and ignore the respective values in this object. See bslmt_threadutil for information about support for this attribute.

◆ operator=()

ThreadAttributes & bslmt::ThreadAttributes::operator= ( const ThreadAttributes rhs)

Assign to this object the value of the specified rhs object, and return a reference providing modifiable access to this object.

◆ print()

bsl::ostream & bslmt::ThreadAttributes::print ( bsl::ostream &  stream,
int  level = 0,
int  spacesPerLevel = 4 
) const

Format this object to the specified output stream at the (absolute value of) the optionally specified indentation level and return a reference to stream. If level is specified, optionally specify spacesPerLevel, the number of spaces per indentation level for this and all of its nested objects. If level is negative, suppress indentation of the first line. If spacesPerLevel is negative format the entire output on one line, suppressing all but the initial indentation (as governed by level). If stream is not valid on entry, this operation has no effect.

◆ schedulingPolicy()

ThreadAttributes::SchedulingPolicy bslmt::ThreadAttributes::schedulingPolicy ( ) const
inline

Return the value of the schedulingPolicy attribute of this object. This attribute is ignored unless inheritSchedule is false. See bslmt_threadutil for information about this attribute.

◆ schedulingPriority()

int bslmt::ThreadAttributes::schedulingPriority ( ) const
inline

Return the value of the schedulingPriority attribute of this object. This attribute is ignored unless inheritSchedule() is false. Higher values of value signify more urgent priorities. Note that the valid range of priorities depends upon the platform and schedulingPolicy attribute, and the minimum and maximum priority values are determined by methods in bslmt_threadutil . See bslmt_threadutil for information about this attribute.

◆ setDetachedState()

ThreadAttributes & bslmt::ThreadAttributes::setDetachedState ( ThreadAttributes::DetachedState  value)
inline

Set the detachedState attribute of this object to the specified value. Return a non-const reference to this object (see also {Fluent Interface}). A value of e_CREATE_JOINABLE (the default) indicates that a thread must be joined to clean up its resources after it terminates; a value of e_CREATE_DETACHED (the only other legal value) indicates that the resources will be cleaned up automatically upon thread termination, and that the thread must not be joined.

◆ setGuardSize()

ThreadAttributes & bslmt::ThreadAttributes::setGuardSize ( int  value)
inline

Set the guardSize attribute of this object to the specified value (in bytes). Return a non-const reference to this object (see also {Fluent Interface}). e_UNSET_GUARD_SIZE == guardSize is intended to indicate that the default value as defined by the platform is to be used. This default value is typically the size of one or two pages (see bslmt_configuration ). The behavior is undefined unless e_UNSET_GUARD_SIZE == guardSize or guardSize >= 0.

◆ setInheritSchedule()

ThreadAttributes & bslmt::ThreadAttributes::setInheritSchedule ( bool  value)
inline

Set the inheritSchedule attribute of this object to the specified value. Return a non-const reference to this object (see also {Fluent Interface}). A value of false for the inherit schedule attribute indicates that a thread should not inherit the scheduling policy and priority of the thread that created it and instead should use the respective values supplied by this object; whereas a value of true indicates that the thread should inherit these attributes and ignore the respective values in this object. See bslmt_threadutil for information about support for this attribute.

◆ setSchedulingPolicy()

ThreadAttributes & bslmt::ThreadAttributes::setSchedulingPolicy ( ThreadAttributes::SchedulingPolicy  value)
inline

Set the value of the schedulingPolicy attribute of this object to the specified value. Return a non-const reference to this object (see also {Fluent Interface}). This attribute is ignored unless inheritSchedule is false. See bslmt_threadutil for information about this attribute.

◆ setSchedulingPriority()

ThreadAttributes & bslmt::ThreadAttributes::setSchedulingPriority ( int  value)
inline

Set the schedulingPriority attribute of this object to the specified value. Return a non-const reference to this object (see also {Fluent Interface}). This attribute is ignored unless inheritSchedule() is false. Higher values of value signify more urgent priorities. Note that the valid range of priorities depends upon the platform and schedulingPolicy attribute, and the minimum and maximum priority values are determined by methods in bslmt_threadutil . See bslmt_threadutil for information about this attribute.

◆ setStackSize()

ThreadAttributes & bslmt::ThreadAttributes::setStackSize ( int  value)
inline

Set the stackSize attribute of this object to the specified value. Return a non-const reference to this object (see also {Fluent Interface}). If stackSize is e_UNSET_STACK_SIZE, thread creation should use the default stack size value provided by bslmt_configuration . The behavior is undefined unless e_UNSET_STACK_SIZE == stackSize or 0 <= stackSize.

◆ setThreadName()

ThreadAttributes & bslmt::ThreadAttributes::setThreadName ( const bslstl::StringRef value)
inline

Set the threadName attribute of this object to the specified value. Return a non-const reference to this object (see also {Fluent Interface}).

◆ stackSize()

int bslmt::ThreadAttributes::stackSize ( ) const
inline

Return the value of the stackSize attribute of this object. If stackSize is e_UNSET_STACK_SIZE, thread creation should use the default stack size value provided by bslmt_configuration .

◆ threadName()

bslstl::StringRef bslmt::ThreadAttributes::threadName ( ) const
inline

Return the threadName attribute of this object. Note that the returned string reference will be invalidated if setThreadName is subsequently called on this object.


The documentation for this class was generated from the following file: