Quick Links:

bal | bbl | bdl | bsl

Public Types | Public Member Functions

bslmt::ThreadAttributes Class Reference

#include <bslmt_threadattributes.h>

List of all members.

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

Detailed Description

This simply constrained (value-semantic) attribute class characterizes a collection of thread attribute values. See the Attributes section under @DESCRIPTION in the component-level documentation.

This class:

For terminology see bsldoc_glossary.

See Component bslmt_threadattributes


Member Enumeration Documentation

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

Enumerator:
e_CREATE_JOINABLE 

create a joinable thread

e_CREATE_DETACHED 

create a non-joinable thread

BCEMT_CREATE_JOINABLE 
BCEMT_CREATE_DETACHED 
CREATE_JOINABLE 
CREATE_DETACHED 

This enumeration provides values used to distinguish between different thread scheduling policies.

Enumerator:
e_SCHED_OTHER 

unspecified, OS-dependent scheduling

e_SCHED_FIFO 

policy

first-in-first-out scheduling policy

e_SCHED_RR 

round-robin scheduling policy

e_SCHED_DEFAULT 

default OS scheduling policy, usually

BCEMT_SCHED_OTHER 
BCEMT_SCHED_FIFO 
BCEMT_SCHED_RR 
BCEMT_SCHED_DEFAULT 
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 

Constructor & Destructor Documentation

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

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

Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

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

bslmt::ThreadAttributes::BSLMF_NESTED_TRAIT_DECLARATION ( ThreadAttributes  ,
bslma::UsesBslmaAllocator   
)
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.

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

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.

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

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.

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

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.

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

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.

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

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.

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

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.

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

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

DetachedState bslmt::ThreadAttributes::detachedState (  )  const

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.

int bslmt::ThreadAttributes::guardSize (  )  const

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.

bool bslmt::ThreadAttributes::inheritSchedule (  )  const

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.

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 bslmt::ThreadAttributes::schedulingPolicy (  )  const

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.

int bslmt::ThreadAttributes::schedulingPriority (  )  const

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.

int bslmt::ThreadAttributes::stackSize (  )  const

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.

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

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

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

Return the allocator used by this object to supply memory.


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