Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
impala::ThreadGroup Class Reference

#include <thread.h>

Collaboration diagram for impala::ThreadGroup:

Public Member Functions

 ThreadGroup ()
 
 ThreadGroup (CgroupsMgr *cgroups_mgr, const std::string &cgroup)
 
Status AddThread (Thread *thread)
 
void JoinAll ()
 
Status SetCgroup (const std::string &cgroup)
 
void SetCgroupsMgr (CgroupsMgr *cgroups_mgr)
 

Private Attributes

boost::ptr_vector< Threadthreads_
 All the threads grouped by this set. More...
 
CgroupsMgrcgroups_mgr_
 Cgroups manager for assigning threads in this group to cgroups. Not owned. More...
 
std::string cgroup_path_
 

Detailed Description

Utility class to group together a set of threads. A replacement for boost::thread_group.

Definition at line 161 of file thread.h.

Constructor & Destructor Documentation

impala::ThreadGroup::ThreadGroup ( )
inline

Definition at line 163 of file thread.h.

impala::ThreadGroup::ThreadGroup ( CgroupsMgr cgroups_mgr,
const std::string &  cgroup 
)
inline

Definition at line 165 of file thread.h.

Member Function Documentation

Status impala::ThreadGroup::AddThread ( Thread thread)

Adds a new Thread to this group. The ThreadGroup takes ownership of the Thread, and will destroy it when the ThreadGroup is destroyed. Threads will linger until that point (even if terminated), however, so callers should be mindful of the cost of placing very many threads in this set. If cgroup_path_ / cgroup_prefix_ are set, the thread will be added to the specified cgroup and an error will be returned if that operation fails.

Definition at line 318 of file thread.cc.

References impala::OK, and RETURN_IF_ERROR.

Referenced by impala::ParallelExecutor::Exec(), impala::DiskIoMgr::Init(), impala::ThreadPool< TRowBatch * >::ThreadPool(), and impala::HdfsScanNode::ThreadTokenAvailableCb().

void impala::ThreadGroup::JoinAll ( )

Waits for all threads to finish. DO NOT call this from a thread inside this set; deadlock will predictably ensue.

Definition at line 327 of file thread.cc.

References impala::Thread::Join().

Referenced by impala::HdfsScanNode::Close(), impala::ParallelExecutor::Exec(), impala::ThreadPool< TRowBatch * >::Join(), and impala::DiskIoMgr::~DiskIoMgr().

Status impala::ThreadGroup::SetCgroup ( const std::string &  cgroup)

Assigns all current and future threads to the given cgroup managed by cgroups_mgr_. Must be called after SetCgroupsMgr() if groups_mgr_ has not been set already. Returns an error if any assignment was not possible, but does not undo previously successful assignments.

Definition at line 333 of file thread.cc.

References impala::OK, and RETURN_IF_ERROR.

Referenced by impala::ThreadPool< TRowBatch * >::AssignToCgroup(), and impala::HdfsScanNode::Prepare().

void impala::ThreadGroup::SetCgroupsMgr ( CgroupsMgr cgroups_mgr)
inline

Definition at line 186 of file thread.h.

References cgroups_mgr_.

Referenced by impala::HdfsScanNode::Prepare().

Member Data Documentation

std::string impala::ThreadGroup::cgroup_path_
private

If not empty, every thread added to this group will also be placed in the cgroup_path_ managed by the cgroups_mgr_.

Definition at line 197 of file thread.h.

CgroupsMgr* impala::ThreadGroup::cgroups_mgr_
private

Cgroups manager for assigning threads in this group to cgroups. Not owned.

Definition at line 193 of file thread.h.

Referenced by SetCgroupsMgr().

boost::ptr_vector<Thread> impala::ThreadGroup::threads_
private

All the threads grouped by this set.

Definition at line 190 of file thread.h.


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