关于c++:Folly库代码赏析7Executor

55次阅读

共计 591 个字符,预计需要花费 2 分钟才能阅读完成。

Folly 的余下内容分为

    • [] synchronization
    • [] memory
    • [] logging
    • [] io
    • [] gen
    • [] fibers
    • [] executors
    • [] concurrency
classDiagram
    Executor
    Executor <|-- IOExecutor
    Executor <|-- ThreadPoolExecutor
    IOExecutor <|-- IOThreadPoolExecutor
    ThreadPoolExecutor <|--    IOThreadPoolExecutor
    ThreadPoolExecutor <|-- CPUThreadPoolExecutor
    Executor <|-- DrivableExecutor
    Executor <|-- ManualExecutor

Executor

KeepAlive是对 Executor 的平安援用,Executor析构时会 join 所有 KeepAlive 对象。

ThreadExecutor

对于每个 task 启动一个线程执行,通过 channel 告诉工作增加、删除、完结。golang中的select channel 用法。

ThreadPoolExecutor

IO/CPUThreadPoolExecutor的基类,提供了统计性能等通用信息。

IOThreadPoolExecutor

提供多个 ioThread,每个ioThread 容许event_base loop

正文完
 0