folly::PriorityThreadFactory

A ThreadFactory that sets nice values for each thread. The main use case for this class is if there are multiple CPUThreadPoolExecutors in a single process, or between multiple processes, where some should have a higher priority than the others.

Synopsis

Declared in <folly/executors/thread_factory/PriorityThreadFactory.h>

class PriorityThreadFactory
    : public InitThreadFactory

Description

Note that per-thread nice values are not POSIX standard, but both pthreads and linux support per-thread nice. The default linux scheduler uses these values to do smart thread prioritization. sched_priority function calls only affect real-time schedulers.

Base Classes

NameDescription
InitThreadFactoryA thread factory that runs setup and teardown callbacks around each thread.

Member Functions

NameDescription
PriorityThreadFactory [constructor]Construct a factory that sets the given nice value on each thread.
getNamePrefix [virtual]Returns the name prefix used by the backing thread factory.
newThread [virtual]Creates a thread that runs the initializer, the function, then the finalizer.