Simplify BackgroundThreads, move them to folly/experimental/ThreadedRepeatingFunction...
authorAlexey Spiridonov <lesha@fb.com>
Fri, 28 Apr 2017 22:52:16 +0000 (15:52 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Fri, 28 Apr 2017 23:10:23 +0000 (16:10 -0700)
commitb7a0f26dcf38f4f632a50053e1fa9dcccb9bad0b
tree05a1b5bc72dbee0a9c5d75281cf585b5a58397d4
parentd5a493396d27b30723e6e4a1fdcfae5970d54dd8
Simplify BackgroundThreads, move them to folly/experimental/ThreadedRepeatingFunctionRunner

Summary:
- `FunctionScheduler` and `EventBase` are great for sharing one thread for many functions, but one-function-per-thread is messy.
- Both of those implementations are complicated, but `FunctionThreads` is dead-simple.
- I made it even simpler by eliminating the former `incrementalSleep` in favor of `std::future::wait_for`, which allows instant interruption without a tweakable param. h/t aru777 for suggesting `std::future` instead of `std::condition_variable`.

Reviewed By: yfeldblum

Differential Revision: D4742134

fbshipit-source-id: b520bbcd5f218b2276200ffe8926722ae8a8d6ca
folly/Makefile.am
folly/experimental/FunctionScheduler.h
folly/experimental/ThreadedRepeatingFunctionRunner.cpp [new file with mode: 0644]
folly/experimental/ThreadedRepeatingFunctionRunner.h [new file with mode: 0644]
folly/experimental/test/ThreadedRepeatingFunctionRunnerTest.cpp [new file with mode: 0644]