X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2Fexecutors%2FIOThreadPoolExecutor.cpp;h=63601fdc9b2c0e37c91ce2e7da894e761100fd8a;hb=7bf1486094cccb266e789a378d8e5f91e3cb7780;hp=1cf9bc5e336d24fbc530df8b68d2eb9366dd1ec8;hpb=af4a335238f0ccefdf8a8e6a2689d3a1d44b584a;p=folly.git diff --git a/folly/executors/IOThreadPoolExecutor.cpp b/folly/executors/IOThreadPoolExecutor.cpp index 1cf9bc5e..63601fdc 100644 --- a/folly/executors/IOThreadPoolExecutor.cpp +++ b/folly/executors/IOThreadPoolExecutor.cpp @@ -47,9 +47,9 @@ class MemoryIdlerTimeout : public AsyncTimeout, public EventBase::LoopCallback { idleTimeout = MemoryIdler::getVariationTimeout(idleTimeout); - scheduleTimeout( + scheduleTimeout(static_cast( std::chrono::duration_cast(idleTimeout) - .count()); + .count())); } // reschedule this callback for the next event loop. @@ -119,11 +119,12 @@ IOThreadPoolExecutor::pickThread() { if (n == 0) { return me; } - auto thread = ths[nextThread_++ % n]; + auto thread = ths[nextThread_.fetch_add(1, std::memory_order_relaxed) % n]; return std::static_pointer_cast(thread); } EventBase* IOThreadPoolExecutor::getEventBase() { + RWSpinLock::ReadHolder r{&threadListLock_}; return pickThread()->eventBase; }