MCPcopy Create free account
hub / github.com/834810071/muduo_study / doPendingFunctors

Method doPendingFunctors

net/EventLoop.cpp:331–352  ·  view source on GitHub ↗

执行任务队列中的任务 1. 不是简单的在临界区内依次调用functor,而是把回调列表swap到functors中,这一方面减小了 临界区的长度,意味着不会阻塞其他线程的queueInLoop(),另一方面也避免了死锁(因为Functor可能再次调用quueInLoop) 2. 由于doPendingFunctors()调用的Functor可能再次调用queueInLoop(cb),这是queueInLoop()就必须wakeup(),否则新增的cb可能就不能及时调用了 3. muduo没有反复执行doPendingFunctors()直到pendingFunctors为空,这是有意的,否则I/O线程可能陷入死循环,无法处理I/O事件

Source from the content-addressed store, hash-verified

source not stored for this graph (policy: none)

Callers

nothing calls this directly

Calls 1

swapMethod · 0.45

Tested by

no test coverage detected