#include <coherence/lang/ThreadGroup.hpp>
Inherits Object.
Public Types | |
typedef spec::Handle | Handle |
ThreadGroup Handle definition. | |
typedef spec::View | View |
ThreadGroup View definition. | |
typedef spec::Holder | Holder |
ThreadGroup Holder definition. | |
Public Member Functions | |
virtual String::View | getName () const |
Return the name of the group. | |
virtual ThreadGroup::View | getParent () const |
Return this groups parent group. | |
virtual void | destroy () |
Destroy this group and all of its subgroups. | |
virtual bool | isDestroyed () const |
Returns true if the group has been destroyed. | |
virtual size32_t | activeCount (bool fRecurse=true) const |
Return an estimate as to the number of threads in the group. | |
virtual size32_t | activeGroupCount (bool fRecurse=true) const |
Return an estimate as to the number of thread groups in the group. | |
virtual size32_t | enumerateThreads (ObjectArray::Handle hao, bool fRecurse=true) |
Copy into the specified array the active threads represented by this group. | |
virtual size32_t | enumerateThreads (ObjectArray::Handle hao, bool fRecurse=true) const |
Copy into the specified array the active threads represented by this group. | |
virtual size32_t | enumerateGroups (ObjectArray::Handle hao, bool fRecurse=true) |
Copy into the specified array the active thread groups represented by this group. | |
virtual size32_t | enumerateGroups (ObjectArray::Handle hao, bool fRecurse=true) const |
Copy into the specified array the active thread groups represented by this group. | |
virtual void | interrupt (bool fRecurse=true) |
Interrupt the threads represented by this group. | |
virtual size32_t | join (int64_t cMillis=0, bool fRecurse=true) const |
Join the threads represented by this group. | |
virtual TypedHandle < const String > | toString () const |
Output a human-readable description of this Object to the given stream. Note that when overriding this method the return type must be TypedHandle<const String> rather then String::View. These two types are assignment compatible but not equivalent and declaring the override with String::View will not be a compatible override. coherence::lang::operator<<(std::ostream, Object::View) is defined and will call into the toString method, to output Objects. If a managed String object is desired, the COH_TO_STRING macro can be used to build up a String from streamable contents and is generally how toString() will be implemented.
Object::View vKey = ... Object::View vValue = ... std::cout << vKey << " = " << vValue << std::endl; String::View vs = COH_TO_STRING(vKey << " = " << vValue); The COH_TO_STRING macro is also the most common way to implement the toString method. For example:
virtual TypedHandle<const String> Person::toString() const { return COH_TO_STRING("Name: " << f_sName << " SSN: " << f_nSSN); }
| |
Protected Member Functions | |
ThreadGroup (String::View vsName, ThreadGroup::Handle hParent=NULL) | |
Create a new ThreadGroup. | |
virtual void | add (TypedHandle< Thread > hThread) |
Add a thread to this group. | |
virtual void | remove (TypedHandle< Thread > hThread) |
Remove a thread from this group. | |
virtual void | addGroup (ThreadGroup::Handle hGroup) |
Add a thread group to this group. | |
virtual void | removeGroup (ThreadGroup::Handle hGroup) |
Remove a thread group from this group. | |
Protected Attributes | |
FinalView< String > | f_vsName |
The group name. | |
MemberHandle < ThreadGroup > | m_hGroupParent |
The parent group. | |
bool | m_fDestroyed |
True if the group has been destroyed. | |
FinalHandle< Object > | f_hSetThreads |
The group's threads. | |
FinalHandle< Object > | f_hSetGroups |
The group's child groups. |
ThreadGroup | ( | String::View | vsName, | |
ThreadGroup::Handle | hParent = NULL | |||
) | [protected] |
Create a new ThreadGroup.
vsName | the name for the group | |
hParent | the parent thread group, or NULL for current group |
virtual String::View getName | ( | ) | const [virtual] |
Return the name of the group.
virtual ThreadGroup::View getParent | ( | ) | const [virtual] |
Return this groups parent group.
virtual void destroy | ( | ) | [virtual] |
Destroy this group and all of its subgroups.
The groups must be empty.
virtual bool isDestroyed | ( | ) | const [virtual] |
Returns true if the group has been destroyed.
virtual size32_t activeCount | ( | bool | fRecurse = true |
) | const [virtual] |
Return an estimate as to the number of threads in the group.
fRecurse | if the count should include sub-groups |
virtual size32_t activeGroupCount | ( | bool | fRecurse = true |
) | const [virtual] |
Return an estimate as to the number of thread groups in the group.
fRecurse | if the count should include sub-groups |
virtual size32_t enumerateThreads | ( | ObjectArray::Handle | hao, | |
bool | fRecurse = true | |||
) | [virtual] |
Copy into the specified array the active threads represented by this group.
hao | the destination array | |
fRecurse | if sub-groups should be enumerated |
virtual size32_t enumerateThreads | ( | ObjectArray::Handle | hao, | |
bool | fRecurse = true | |||
) | const [virtual] |
Copy into the specified array the active threads represented by this group.
hao | the destination array | |
fRecurse | if sub-groups should be enumerated |
virtual size32_t enumerateGroups | ( | ObjectArray::Handle | hao, | |
bool | fRecurse = true | |||
) | [virtual] |
Copy into the specified array the active thread groups represented by this group.
hao | the destination array | |
fRecurse | if sub-groups should be enumerated |
virtual size32_t enumerateGroups | ( | ObjectArray::Handle | hao, | |
bool | fRecurse = true | |||
) | const [virtual] |
Copy into the specified array the active thread groups represented by this group.
hao | the destination array | |
fRecurse | if sub-groups should be enumerated |
virtual void interrupt | ( | bool | fRecurse = true |
) | [virtual] |
Interrupt the threads represented by this group.
fRecurse | if sub-groups should be enumerated |
virtual size32_t join | ( | int64_t | cMillis = 0 , |
|
bool | fRecurse = true | |||
) | const [virtual] |
Join the threads represented by this group.
cMillis | the total join timeout, or zero for infinite | |
fRecurse | if sub-groups should be enumerated |
virtual void add | ( | TypedHandle< Thread > | hThread | ) | [protected, virtual] |
Add a thread to this group.
hThread | the thread to add |
virtual void remove | ( | TypedHandle< Thread > | hThread | ) | [protected, virtual] |
Remove a thread from this group.
hThread | the thread to remove |
virtual void addGroup | ( | ThreadGroup::Handle | hGroup | ) | [protected, virtual] |
Add a thread group to this group.
hGroup | the group to add |
virtual void removeGroup | ( | ThreadGroup::Handle | hGroup | ) | [protected, virtual] |
Remove a thread group from this group.
hGroup | the group to remove |