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
aac47db4
Commit
aac47db4
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
adding example for things that require set_done (#31)
fbshipit-source-id: a79daf051453f6b189330891fa290be4e9cd6549
parent
5ab9aa60
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
172 additions
and
2 deletions
+172
-2
folly/experimental/pushmi/buildSingleHeader.cmake
folly/experimental/pushmi/buildSingleHeader.cmake
+1
-0
folly/experimental/pushmi/examples/CMakeLists.txt
folly/experimental/pushmi/examples/CMakeLists.txt
+1
-0
folly/experimental/pushmi/examples/set_done/CMakeLists.txt
folly/experimental/pushmi/examples/set_done/CMakeLists.txt
+7
-0
folly/experimental/pushmi/examples/set_done/set_done_2.cpp
folly/experimental/pushmi/examples/set_done/set_done_2.cpp
+64
-0
folly/experimental/pushmi/include/pushmi.h
folly/experimental/pushmi/include/pushmi.h
+50
-2
folly/experimental/pushmi/include/pushmi/o/filter.h
folly/experimental/pushmi/include/pushmi/o/filter.h
+49
-0
No files found.
folly/experimental/pushmi/buildSingleHeader.cmake
View file @
aac47db4
...
@@ -51,6 +51,7 @@ set(header_files
...
@@ -51,6 +51,7 @@ set(header_files
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include/pushmi/o/on.h"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include/pushmi/o/on.h"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include/pushmi/o/tap.h"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include/pushmi/o/tap.h"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include/pushmi/o/transform.h"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include/pushmi/o/transform.h"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include/pushmi/o/filter.h"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include/pushmi/o/via.h"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include/pushmi/o/via.h"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include/pushmi/o/request_via.h"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include/pushmi/o/request_via.h"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include/pushmi/o/share.h"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include/pushmi/o/share.h"
...
...
folly/experimental/pushmi/examples/CMakeLists.txt
View file @
aac47db4
...
@@ -9,3 +9,4 @@ add_subdirectory(then_execute)
...
@@ -9,3 +9,4 @@ add_subdirectory(then_execute)
add_subdirectory
(
composition
)
add_subdirectory
(
composition
)
add_subdirectory
(
for_each
)
add_subdirectory
(
for_each
)
add_subdirectory
(
reduce
)
add_subdirectory
(
reduce
)
add_subdirectory
(
set_done
)
folly/experimental/pushmi/examples/set_done/CMakeLists.txt
0 → 100644
View file @
aac47db4
add_executable
(
set_done_2 set_done_2.cpp
)
target_link_libraries
(
set_done_2
pushmi
examples
Threads::Threads
)
folly/experimental/pushmi/examples/set_done/set_done_2.cpp
0 → 100644
View file @
aac47db4
#include <vector>
#include <algorithm>
#include <cassert>
#include <iostream>
#include <pushmi/o/just.h>
#include <pushmi/o/tap.h>
#include <pushmi/o/filter.h>
#include <pushmi/o/transform.h>
#include <pushmi/o/empty.h>
using
namespace
pushmi
::
aliases
;
const
bool
setting_exists
=
false
;
auto
get_setting
()
{
return
mi
::
make_single_deferred
(
[](
auto
out
){
if
(
setting_exists
)
{
op
::
just
(
42
)
|
op
::
submit
(
out
);
}
else
{
op
::
empty
<
int
>
()
|
op
::
submit
(
out
);
}
}
);
}
auto
println
=
[](
auto
v
){
std
::
cout
<<
v
<<
std
::
endl
;};
// concat not yet implemented
auto
concat
=
[](
auto
in
){
return
mi
::
make_single_deferred
(
[
in
](
auto
out
)
mutable
{
::
pushmi
::
submit
(
in
,
mi
::
make_single
(
out
,
[](
auto
out
,
auto
v
){
// ::pushmi::submit(v, out);
}));
});
};
int
main
()
{
get_setting
()
|
op
::
transform
([](
int
i
){
return
std
::
to_string
(
i
);
})
|
op
::
submit
(
println
);
op
::
just
(
42
)
|
op
::
filter
([](
int
i
){
return
i
<
42
;
})
|
op
::
transform
([](
int
i
){
return
std
::
to_string
(
i
);
})
|
op
::
submit
(
println
);
op
::
just
(
42
)
|
op
::
transform
([](
int
i
)
{
if
(
i
<
42
)
{
return
mi
::
any_single_deferred
<
std
::
string
>
{
op
::
empty
<
std
::
string
>
()};
}
return
mi
::
any_single_deferred
<
std
::
string
>
{
op
::
just
(
std
::
to_string
(
i
))};
})
|
concat
|
op
::
submit
(
println
);
std
::
cout
<<
"OK"
<<
std
::
endl
;
}
folly/experimental/pushmi/include/pushmi.h
View file @
aac47db4
...
@@ -922,7 +922,6 @@ PUSHMI_CONCEPT_DEF(
...
@@ -922,7 +922,6 @@ PUSHMI_CONCEPT_DEF(
#if __cpp_lib_invoke >= 201411
#if __cpp_lib_invoke >= 201411
using
std
::
invoke
;
using
std
::
invoke
;
using
std
::
invoke_result_t
;
#else
#else
PUSHMI_TEMPLATE
(
class
F
,
class
...
As
)
PUSHMI_TEMPLATE
(
class
F
,
class
...
As
)
(
requires
requires
(
(
requires
requires
(
...
@@ -940,10 +939,10 @@ decltype(auto) invoke(F f, As&&...as)
...
@@ -940,10 +939,10 @@ decltype(auto) invoke(F f, As&&...as)
noexcept
(
noexcept
(
std
::
declval
<
decltype
(
std
::
mem_fn
(
f
))
>
()((
As
&&
)
as
...)))
{
noexcept
(
noexcept
(
std
::
declval
<
decltype
(
std
::
mem_fn
(
f
))
>
()((
As
&&
)
as
...)))
{
return
std
::
mem_fn
(
f
)((
As
&&
)
as
...);
return
std
::
mem_fn
(
f
)((
As
&&
)
as
...);
}
}
#endif
template
<
class
F
,
class
...
As
>
template
<
class
F
,
class
...
As
>
using
invoke_result_t
=
using
invoke_result_t
=
decltype
(
pushmi
::
invoke
(
std
::
declval
<
F
>
(),
std
::
declval
<
As
>
()...));
decltype
(
pushmi
::
invoke
(
std
::
declval
<
F
>
(),
std
::
declval
<
As
>
()...));
#endif
PUSHMI_CONCEPT_DEF
(
PUSHMI_CONCEPT_DEF
(
template
(
class
F
,
class
...
Args
)
template
(
class
F
,
class
...
Args
)
...
@@ -6113,6 +6112,55 @@ PUSHMI_INLINE_VAR constexpr detail::transform_fn transform{};
...
@@ -6113,6 +6112,55 @@ PUSHMI_INLINE_VAR constexpr detail::transform_fn transform{};
// This source code is licensed under the MIT license found in the
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
// LICENSE file in the root directory of this source tree.
//#include "../piping.h"
//#include "extension_operators.h"
namespace
pushmi
{
namespace
detail
{
struct
filter_fn
{
PUSHMI_TEMPLATE
(
class
Predicate
)
(
requires
SemiMovable
<
Predicate
>
)
auto
operator
()(
Predicate
p
)
const
{
return
constrain
(
lazy
::
Sender
<
_1
>
,
[
p
=
std
::
move
(
p
)](
auto
in
)
{
using
In
=
decltype
(
in
);
return
::
pushmi
::
detail
::
deferred_from
<
In
,
single
<>>
(
std
::
move
(
in
),
::
pushmi
::
detail
::
submit_transform_out
<
In
>
(
constrain
(
lazy
::
Receiver
<
_1
>
,
[
p
](
auto
out
)
{
using
Out
=
decltype
(
out
);
return
::
pushmi
::
detail
::
out_from_fn
<
In
>
()(
std
::
move
(
out
),
// copy 'p' to allow multiple calls to submit
::
pushmi
::
on_value
([
p
](
auto
&
out
,
auto
&&
v
)
{
if
(
p
(
as_const
(
v
)))
{
::
pushmi
::
set_value
(
out
,
std
::
move
(
v
));
}
else
{
::
pushmi
::
set_done
(
out
);
}
})
);
})
)
);
});
}
};
}
// namespace detail
namespace
operators
{
PUSHMI_INLINE_VAR
constexpr
detail
::
filter_fn
filter
{};
}
// namespace operators
}
// namespace pushmi
//#pragma once
// Copyright (c) 2018-present, Facebook, Inc.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
//#include "../piping.h"
//#include "../piping.h"
//#include "../executor.h"
//#include "../executor.h"
//#include "extension_operators.h"
//#include "extension_operators.h"
...
...
folly/experimental/pushmi/include/pushmi/o/filter.h
0 → 100644
View file @
aac47db4
#pragma once
// Copyright (c) 2018-present, Facebook, Inc.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
#include "../piping.h"
#include "extension_operators.h"
namespace
pushmi
{
namespace
detail
{
struct
filter_fn
{
PUSHMI_TEMPLATE
(
class
Predicate
)
(
requires
SemiMovable
<
Predicate
>
)
auto
operator
()(
Predicate
p
)
const
{
return
constrain
(
lazy
::
Sender
<
_1
>
,
[
p
=
std
::
move
(
p
)](
auto
in
)
{
using
In
=
decltype
(
in
);
return
::
pushmi
::
detail
::
deferred_from
<
In
,
single
<>>
(
std
::
move
(
in
),
::
pushmi
::
detail
::
submit_transform_out
<
In
>
(
constrain
(
lazy
::
Receiver
<
_1
>
,
[
p
](
auto
out
)
{
using
Out
=
decltype
(
out
);
return
::
pushmi
::
detail
::
out_from_fn
<
In
>
()(
std
::
move
(
out
),
// copy 'p' to allow multiple calls to submit
::
pushmi
::
on_value
([
p
](
auto
&
out
,
auto
&&
v
)
{
if
(
p
(
as_const
(
v
)))
{
::
pushmi
::
set_value
(
out
,
std
::
move
(
v
));
}
else
{
::
pushmi
::
set_done
(
out
);
}
})
);
})
)
);
});
}
};
}
// namespace detail
namespace
operators
{
PUSHMI_INLINE_VAR
constexpr
detail
::
filter_fn
filter
{};
}
// namespace operators
}
// namespace pushmi
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