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
3e05ecc2
Commit
3e05ecc2
authored
Oct 16, 2018
by
Kirk Shoop
Committed by
Facebook Github Bot
Oct 17, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merging examples (#17)
fbshipit-source-id: 0e4317ea86a60c50408cf415972bd048596ac0b2
parent
39d4be19
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
49 additions
and
43 deletions
+49
-43
folly/experimental/pushmi/examples/composition/composition_3.cpp
...xperimental/pushmi/examples/composition/composition_3.cpp
+6
-9
folly/experimental/pushmi/examples/composition/composition_4.cpp
...xperimental/pushmi/examples/composition/composition_4.cpp
+4
-7
folly/experimental/pushmi/examples/include/pool.h
folly/experimental/pushmi/examples/include/pool.h
+8
-1
folly/experimental/pushmi/examples/then_execute/then_execute_2.cpp
...erimental/pushmi/examples/then_execute/then_execute_2.cpp
+3
-6
folly/experimental/pushmi/examples/twoway_execute/twoway_execute_2.cpp
...ental/pushmi/examples/twoway_execute/twoway_execute_2.cpp
+2
-5
folly/experimental/pushmi/include/pushmi.h
folly/experimental/pushmi/include/pushmi.h
+2
-0
folly/experimental/pushmi/include/pushmi/o/defer.h
folly/experimental/pushmi/include/pushmi/o/defer.h
+12
-5
folly/experimental/pushmi/include/pushmi/o/just.h
folly/experimental/pushmi/include/pushmi/o/just.h
+2
-0
folly/experimental/pushmi/include/pushmi/o/request_via.h
folly/experimental/pushmi/include/pushmi/o/request_via.h
+5
-5
folly/experimental/pushmi/include/pushmi/o/share.h
folly/experimental/pushmi/include/pushmi/o/share.h
+5
-5
folly/experimental/pushmi/include/pushmi/subject.h
folly/experimental/pushmi/include/pushmi/subject.h
+0
-0
No files found.
folly/experimental/pushmi/examples/composition/composition_3.cpp
View file @
3e05ecc2
...
...
@@ -3,22 +3,22 @@
#include <cassert>
#include <iostream>
#include <defer.h>
#include <share.h>
#include <
pushmi/o/
defer.h>
#include <
pushmi/o/
share.h>
#include <pushmi/o/just.h>
#include <pushmi/o/tap.h>
using
namespace
pushmi
::
aliases
;
// three models of submission deferral
// (none of these use an executor, they are all running
// three models of submission deferral
// (none of these use an executor, they are all running
// synchronously on the main thread)
// this constructs eagerly and submits just() lazily
auto
defer_execution
()
{
printf
(
"construct just
\n
"
);
return
op
::
just
(
42
)
|
return
op
::
just
(
42
)
|
op
::
tap
([](
int
v
){
printf
(
"just - %d
\n
"
,
v
);
});
}
...
...
@@ -36,7 +36,7 @@ auto eager_execution() {
int
main
()
{
printf
(
"
\n
call defer_execution
\n
"
);
auto
de
=
defer_execution
();
printf
(
"submit defer_execution
\n
"
);
...
...
@@ -67,6 +67,3 @@ int main()
std
::
cout
<<
"OK"
<<
std
::
endl
;
// OK
}
folly/experimental/pushmi/examples/composition/composition_4.cpp
View file @
3e05ecc2
...
...
@@ -5,7 +5,7 @@
#include <pool.h>
#include <request_via.h>
#include <
pushmi/o/
request_via.h>
#include <pushmi/o/tap.h>
#include <pushmi/o/transform.h>
...
...
@@ -14,7 +14,7 @@ using namespace pushmi::aliases;
template
<
class
Io
>
auto
io_operation
(
Io
io
)
{
return
io
|
return
io
|
op
::
transform
([](
auto
){
return
42
;
})
|
op
::
tap
([](
int
v
){
printf
(
"io pool producing, %d
\n
"
,
v
);
})
|
op
::
request_via
();
...
...
@@ -28,13 +28,13 @@ int main()
auto
io
=
ioPool
.
executor
();
auto
cpu
=
cpuPool
.
executor
();
io_operation
(
io
).
via
([
cpu
]{
return
cpu
;
})
|
io_operation
(
io
).
via
([
cpu
]{
return
cpu
;
})
|
op
::
tap
([](
int
v
){
printf
(
"cpu pool processing, %d
\n
"
,
v
);
})
|
op
::
submit
();
// when the caller is not going to process the result (only side-effect matters)
// or the caller is just going to push the result into a queue.
// provide a way to skip the transition to a different executor and make it
// provide a way to skip the transition to a different executor and make it
// stand out so that it has to be justified in code reviews.
mi
::
via_cast
<
mi
::
is_sender
<>>
(
io_operation
(
io
))
|
op
::
submit
();
...
...
@@ -43,6 +43,3 @@ int main()
std
::
cout
<<
"OK"
<<
std
::
endl
;
}
folly/experimental/pushmi/examples/include/pool.h
View file @
3e05ecc2
...
...
@@ -10,6 +10,13 @@
#include <pushmi/executor.h>
#include <pushmi/trampoline.h>
#if __cpp_deduction_guides >= 201703
#define MAKE(x) x MAKE_
#define MAKE_(...) {__VA_ARGS__}
#else
#define MAKE(x) make_ ## x
#endif
namespace
pushmi
{
using
std
::
experimental
::
static_thread_pool
;
...
...
@@ -38,7 +45,7 @@ public:
inline
auto
executor
()
{
auto
exec
=
execution
::
require
(
p
.
executor
(),
execution
::
never_blocking
,
execution
::
oneway
);
return
make_time_single_deferred
(
__pool_submit
<
decltype
(
exec
)
>
{
exec
});
return
MAKE
(
time_single_deferred
)
(
__pool_submit
<
decltype
(
exec
)
>
{
exec
});
}
inline
void
stop
()
{
p
.
stop
();}
...
...
folly/experimental/pushmi/examples/then_execute/then_execute_2.cpp
View file @
3e05ecc2
...
...
@@ -13,12 +13,10 @@
#include <pool.h>
#include <request_via.h>
#include <share.h>
#include <pushmi/deferred.h>
#include <pushmi/single_deferred.h>
#include <pushmi/o/just.h>
#include <pushmi/o/via.h>
#include <pushmi/o/transform.h>
using
namespace
pushmi
::
aliases
;
...
...
@@ -38,8 +36,8 @@ public:
};
namespace
p1054
{
// A promise refers to a promise and is associated with a future,
// either through type-erasure or through construction of an
// A promise refers to a promise and is associated with a future,
// either through type-erasure or through construction of an
// underlying promise with an overload of make_promise_contract().
// make_promise_contract() cannot be written to produce a lazy future.
...
...
@@ -103,4 +101,3 @@ int main()
std
::
cout
<<
"OK"
<<
std
::
endl
;
}
folly/experimental/pushmi/examples/twoway_execute/twoway_execute_2.cpp
View file @
3e05ecc2
...
...
@@ -12,9 +12,6 @@
#include <pool.h>
#include <request_via.h>
#include <share.h>
#include <pushmi/deferred.h>
#include <pushmi/single_deferred.h>
#include <pushmi/o/transform.h>
...
...
@@ -22,8 +19,8 @@
using
namespace
pushmi
::
aliases
;
namespace
p1054
{
// A promise refers to a promise and is associated with a future,
// either through type-erasure or through construction of an
// A promise refers to a promise and is associated with a future,
// either through type-erasure or through construction of an
// underlying promise with an overload of make_promise_contract().
// make_promise_contract() cannot be written to produce a lazy future.
...
...
folly/experimental/pushmi/include/pushmi.h
View file @
3e05ecc2
...
...
@@ -8625,6 +8625,8 @@ PUSHMI_INLINE_VAR constexpr detail::now_fn top{};
// LICENSE file in the root directory of this source tree.
//#include "../single_deferred.h"
//#include "submit.h"
//#include "extension_operators.h"
namespace
pushmi
{
...
...
folly/experimental/pushmi/
examples/include
/defer.h
→
folly/experimental/pushmi/
include/pushmi/o
/defer.h
View file @
3e05ecc2
...
...
@@ -6,9 +6,16 @@
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
#include <pushmi/single.h>
#include <pushmi/o/submit.h>
#include <pushmi/o/extension_operators.h>
#include "../single.h"
#include "submit.h"
#include "extension_operators.h"
#if __cpp_deduction_guides >= 201703
#define MAKE(x) x MAKE_
#define MAKE_(...) {__VA_ARGS__}
#else
#define MAKE(x) make_ ## x
#endif
namespace
pushmi
{
...
...
@@ -17,8 +24,8 @@ namespace operators {
PUSHMI_TEMPLATE
(
class
F
)
(
requires
Invocable
<
F
>
)
auto
defer
(
F
f
)
{
return
make_single_deferred
(
constrain
(
lazy
::
Receiver
<
_1
>
,
return
MAKE
(
single_deferred
)
(
constrain
(
lazy
::
Receiver
<
_1
>
,
[
f
=
std
::
move
(
f
)](
auto
out
)
mutable
{
auto
sender
=
f
();
PUSHMI_IF_CONSTEXPR
(
((
bool
)
TimeSender
<
decltype
(
sender
)
>
)
(
...
...
folly/experimental/pushmi/include/pushmi/o/just.h
View file @
3e05ecc2
...
...
@@ -7,6 +7,8 @@
// LICENSE file in the root directory of this source tree.
#include "../single_deferred.h"
#include "submit.h"
#include "extension_operators.h"
namespace
pushmi
{
...
...
folly/experimental/pushmi/
examples/include
/request_via.h
→
folly/experimental/pushmi/
include/pushmi/o
/request_via.h
View file @
3e05ecc2
...
...
@@ -6,10 +6,10 @@
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
#include
<pushmi/single.h>
#include
<pushmi/o/submit.h>
#include
<pushmi/o/extension_operators.h>
#include
<pushmi/o/via.h>
#include
"../single.h"
#include
"submit.h"
#include
"extension_operators.h"
#include
"via.h"
namespace
pushmi
{
...
...
@@ -38,7 +38,7 @@ auto request_via_fn::operator()() const {
namespace
operators
{
PUSHMI_INLINE_VAR
constexpr
detail
::
request_via_fn
request_via
{};
PUSHMI_INLINE_VAR
constexpr
detail
::
request_via_fn
request_via
{};
}
// namespace operators
...
...
folly/experimental/pushmi/
examples/include
/share.h
→
folly/experimental/pushmi/
include/pushmi/o
/share.h
View file @
3e05ecc2
...
...
@@ -6,11 +6,11 @@
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
#include
<pushmi/single.h>
#include
<pushmi/o/submit.h>
#include
<pushmi/o/extension_operators.h>
#include
"../single.h"
#include
"submit.h"
#include
"extension_operators.h"
#include
<subject.h>
#include
"../subject.h"
namespace
pushmi
{
...
...
@@ -42,7 +42,7 @@ auto share_fn<T>::operator()() const {
namespace
operators
{
template
<
class
T
>
PUSHMI_INLINE_VAR
constexpr
detail
::
share_fn
<
T
>
share
{};
PUSHMI_INLINE_VAR
constexpr
detail
::
share_fn
<
T
>
share
{};
}
// namespace operators
...
...
folly/experimental/pushmi/
examples/include
/subject.h
→
folly/experimental/pushmi/
include/pushmi
/subject.h
View file @
3e05ecc2
File moved
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