Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
folly
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
folly
Commits
3fb62b36
Commit
3fb62b36
authored
Feb 21, 2014
by
Hans Fugal
Committed by
Dave Watson
Feb 28, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(wangle) more comment tweaks
Test Plan: eyeballs Reviewed By: hannesr@fb.com FB internal diff: D1185813
parent
07b986bf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
7 deletions
+14
-7
folly/wangle/GenericThreadGate.h
folly/wangle/GenericThreadGate.h
+6
-0
folly/wangle/Later.h
folly/wangle/Later.h
+3
-3
folly/wangle/ThreadGate.h
folly/wangle/ThreadGate.h
+5
-4
No files found.
folly/wangle/GenericThreadGate.h
View file @
3fb62b36
...
...
@@ -21,6 +21,11 @@
namespace
folly
{
namespace
wangle
{
/// This generic threadgate takes two executors and an optional waiter (if you
/// need to support waiting). Hint: use executors that inherit from Executor
/// (in Executor.h), then you just do
///
/// GenericThreadGate tg(westExecutor, eastExecutor, waiter);
template
<
class
WestExecutorPtr
=
Executor
*
,
class
EastExecutorPtr
=
Executor
*
,
...
...
@@ -52,6 +57,7 @@ public:
WestExecutorPtr
westExecutor
;
EastExecutorPtr
eastExecutor
;
WaiterPtr
waiter
;
private:
void
makeProgress_
(
std
::
true_type
const
&
)
{
throw
std
::
logic_error
(
"No waiter."
);
...
...
folly/wangle/Later.h
View file @
3fb62b36
...
...
@@ -110,18 +110,18 @@ class Later {
/*
* Resets the executor - all then() calls made after the call to via() will be
* made in the new executor.
* made in the new executor.
The Executor must outlive.
*/
Later
<
T
>
via
(
Executor
*
executor
);
/*
* Starts the workflow. The function provided in the constructor will be
* called in the executor provided in the constructor.
All proximate
then()
* called in the executor provided in the constructor.
Subsequent
then()
* calls will be made, potentially changing threads if a via() call is made.
* The future returned will be fulfilled in the last executor.
*
* Thread safety issues of Futures still apply. If you want to wait on the
* Future, it must be done in the thread that will fulfil
l
it. If you do not
* Future, it must be done in the thread that will fulfil it. If you do not
* plan to use the result of the Future, use fireAndForget()
*/
Future
<
T
>
launch
();
...
...
folly/wangle/ThreadGate.h
View file @
3fb62b36
...
...
@@ -49,9 +49,7 @@ namespace folly { namespace wangle {
In order to make and use a ThreadGate, you need to provide a strategy for
executing code in the east and west threads. These strategies may be
different. The only requirement is a threadsafe method
`void add(function<void()>&&)`. You may find the executors in
Executor.h handy, but ensure that you are using them
threadsafely.
`void add(function<void()>&&)`.
In order for your ThreadGate to do anything, you need to drive those
executors somehow. An event loop is a natural fit. A thread pool might be
...
...
@@ -69,6 +67,9 @@ namespace folly { namespace wangle {
Future change toward a multithreaded architecture easier, as you need only
change the components of the ThreadGate which your client code is already
using.
Later (in Later.h) is an alternative mechanism for thread-traversing
asynchronous workflows.
*/
class
ThreadGate
{
public:
...
...
@@ -105,7 +106,7 @@ public:
In summary, both east and west need to have plans to drive their
executors, or nothing will actually happen. When the executors are driven,
then everything flows.
*/
then everything flows. */
template
<
class
T
>
Future
<
T
>
gate
(
std
::
function
<
Future
<
T
>
()
>&&
fn
)
{
Promise
<
T
>
pWest
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment