proxygen
folly::ThreadPoolExecutor::ThreadList Class Reference

#include <ThreadPoolExecutor.h>

Public Member Functions

void add (const ThreadPtr &state)
 
void remove (const ThreadPtr &state)
 
const std::vector< ThreadPtr > & get () const
 

Static Private Member Functions

static bool compare (const ThreadPtr &ts1, const ThreadPtr &ts2)
 

Private Attributes

std::vector< ThreadPtrvec_
 

Detailed Description

Definition at line 229 of file ThreadPoolExecutor.h.

Member Function Documentation

void folly::ThreadPoolExecutor::ThreadList::add ( const ThreadPtr state)
inline

Definition at line 231 of file ThreadPoolExecutor.h.

Referenced by folly::ThreadPoolExecutor::addThreads().

231  {
232  auto it = std::lower_bound(
233  vec_.begin(),
234  vec_.end(),
235  state,
236  // compare method is a static method of class
237  // and therefore cannot be inlined by compiler
238  // as a template predicate of the STL algorithm
239  // but wrapped up with the lambda function (lambda will be inlined)
240  // compiler can inline compare method as well
241  [&](const ThreadPtr& ts1, const ThreadPtr& ts2) -> bool { // inline
242  return compare(ts1, ts2);
243  });
244  vec_.insert(it, state);
245  }
static bool compare(const ThreadPtr &ts1, const ThreadPtr &ts2)
std::shared_ptr< Thread > ThreadPtr
state
Definition: http_parser.c:272
static bool folly::ThreadPoolExecutor::ThreadList::compare ( const ThreadPtr ts1,
const ThreadPtr ts2 
)
inlinestaticprivate

Definition at line 266 of file ThreadPoolExecutor.h.

266  {
267  return ts1->id < ts2->id;
268  }
void folly::ThreadPoolExecutor::ThreadList::remove ( const ThreadPtr state)
inline

Definition at line 247 of file ThreadPoolExecutor.h.

References cpp.ast::next().

Referenced by folly::IOThreadPoolExecutor::stopThreads(), and folly::CPUThreadPoolExecutor::threadRun().

247  {
248  auto itPair = std::equal_range(
249  vec_.begin(),
250  vec_.end(),
251  state,
252  // the same as above
253  [&](const ThreadPtr& ts1, const ThreadPtr& ts2) -> bool { // inline
254  return compare(ts1, ts2);
255  });
256  CHECK(itPair.first != vec_.end());
257  CHECK(std::next(itPair.first) == itPair.second);
258  vec_.erase(itPair.first);
259  }
static bool compare(const ThreadPtr &ts1, const ThreadPtr &ts2)
std::shared_ptr< Thread > ThreadPtr
state
Definition: http_parser.c:272
def next(obj)
Definition: ast.py:58

Member Data Documentation

std::vector<ThreadPtr> folly::ThreadPoolExecutor::ThreadList::vec_
private

Definition at line 270 of file ThreadPoolExecutor.h.


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