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
492ce4ff
Commit
492ce4ff
authored
Oct 16, 2018
by
Eric Niebler
Committed by
Facebook Github Bot
Oct 17, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace some lambdas with less-parameterized function objects
fbshipit-source-id: 78678cd0f18440a8ece264e83e303c568354bdaa
parent
4fdee04d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
98 additions
and
61 deletions
+98
-61
folly/experimental/pushmi/examples/include/bulk.h
folly/experimental/pushmi/examples/include/bulk.h
+20
-24
folly/experimental/pushmi/examples/include/for_each.h
folly/experimental/pushmi/examples/include/for_each.h
+36
-17
folly/experimental/pushmi/examples/include/no_fail.h
folly/experimental/pushmi/examples/include/no_fail.h
+6
-3
folly/experimental/pushmi/examples/include/pool.h
folly/experimental/pushmi/examples/include/pool.h
+1
-1
folly/experimental/pushmi/examples/include/reduce.h
folly/experimental/pushmi/examples/include/reduce.h
+35
-16
No files found.
folly/experimental/pushmi/examples/include/bulk.h
View file @
492ce4ff
...
@@ -7,35 +7,31 @@
...
@@ -7,35 +7,31 @@
#include <pushmi/single_deferred.h>
#include <pushmi/single_deferred.h>
#if __cpp_deduction_guides >= 201703
#define MAKE(x) x MAKE_
#define MAKE_(...) {__VA_ARGS__}
#else
#define MAKE(x) make_ ## x
#endif
namespace
pushmi
{
namespace
pushmi
{
namespace
operators
{
namespace
operators
{
template
<
class
F
,
class
ShapeBegin
,
class
ShapeEnd
,
class
Target
,
class
IF
,
class
RS
>
PUSHMI_INLINE_VAR
constexpr
struct
bulk_fn
{
auto
bulk
(
template
<
class
F
,
class
ShapeBegin
,
class
ShapeEnd
,
class
Target
,
class
IF
,
class
RS
>
auto
operator
()(
F
&&
func
,
F
&&
func
,
ShapeBegin
sb
,
ShapeBegin
sb
,
ShapeEnd
se
,
ShapeEnd
se
,
Target
&&
driver
,
Target
&&
driver
,
IF
&&
initFunc
,
IF
&&
initFunc
,
RS
&&
selector
)
{
RS
&&
selector
)
const
{
return
[
func
,
sb
,
se
,
driver
,
initFunc
,
selector
](
auto
in
){
return
[
func
,
sb
,
se
,
driver
,
initFunc
,
selector
](
auto
in
){
return
MAKE
(
single_deferred
)([
in
,
func
,
sb
,
se
,
driver
,
initFunc
,
selector
](
auto
out
)
mutable
{
return
make_single_deferred
(
submit
(
in
,
MAKE
(
single
)(
std
::
move
(
out
),
[
in
,
func
,
sb
,
se
,
driver
,
initFunc
,
selector
](
auto
out
)
mutable
{
[
func
,
sb
,
se
,
driver
,
initFunc
,
selector
](
auto
&
out
,
auto
input
){
submit
(
in
,
make_single
(
std
::
move
(
out
),
[
func
,
sb
,
se
,
driver
,
initFunc
,
selector
](
auto
&
out
,
auto
input
)
{
driver
(
initFunc
,
selector
,
std
::
move
(
input
),
func
,
sb
,
se
,
std
::
move
(
out
));
driver
(
initFunc
,
selector
,
std
::
move
(
input
),
func
,
sb
,
se
,
std
::
move
(
out
));
}
}
));
));
});
});
};
};
}
}
}
bulk
{};
}
// namespace operators
}
// namespace operators
...
...
folly/experimental/pushmi/examples/include/for_each.h
View file @
492ce4ff
...
@@ -11,22 +11,41 @@
...
@@ -11,22 +11,41 @@
namespace
pushmi
{
namespace
pushmi
{
template
<
class
ExecutionPolicy
,
class
RandomAccessIterator
,
class
Function
>
PUSHMI_INLINE_VAR
constexpr
struct
for_each_fn
{
void
for_each
(
private:
template
<
class
Function
>
struct
fn
{
Function
f_
;
template
<
class
Cursor
>
void
operator
()(
detail
::
any
,
Cursor
cursor
)
const
{
f_
(
*
cursor
);
}
};
struct
identity
{
template
<
class
T
>
auto
operator
()(
T
&&
t
)
const
{
return
(
T
&&
)
t
;
}
};
struct
zero
{
int
operator
()(
detail
::
any
)
const
noexcept
{
return
0
;
}
};
public:
template
<
class
ExecutionPolicy
,
class
RandomAccessIterator
,
class
Function
>
void
operator
()(
ExecutionPolicy
&&
policy
,
ExecutionPolicy
&&
policy
,
RandomAccessIterator
begin
,
RandomAccessIterator
begin
,
RandomAccessIterator
end
,
RandomAccessIterator
end
,
Function
f
)
Function
f
)
const
{
{
operators
::
just
(
0
)
|
operators
::
just
(
0
)
|
operators
::
bulk
(
operators
::
bulk
(
[
f
](
auto
&
acc
,
auto
cursor
){
f
(
*
cursor
);
},
fn
<
Function
>
{
f
},
begin
,
begin
,
end
,
end
,
policy
,
policy
,
[](
auto
&&
args
){
return
args
;
},
identity
{},
[](
auto
&&
acc
){
return
0
;
})
|
zero
{}
)
|
operators
::
blocking_submit
();
operators
::
blocking_submit
();
}
}
}
for_each
{};
}
// namespace pushmi
}
// namespace pushmi
folly/experimental/pushmi/examples/include/no_fail.h
View file @
492ce4ff
...
@@ -13,6 +13,11 @@ namespace detail {
...
@@ -13,6 +13,11 @@ namespace detail {
struct
no_fail_fn
{
struct
no_fail_fn
{
private:
private:
struct
on_error_impl
{
void
operator
()(
any
,
any
)
noexcept
{
std
::
abort
();
}
};
template
<
class
In
>
template
<
class
In
>
struct
out_impl
{
struct
out_impl
{
PUSHMI_TEMPLATE
(
class
Out
)
PUSHMI_TEMPLATE
(
class
Out
)
...
@@ -20,9 +25,7 @@ private:
...
@@ -20,9 +25,7 @@ private:
auto
operator
()(
Out
out
)
const
{
auto
operator
()(
Out
out
)
const
{
return
::
pushmi
::
detail
::
out_from_fn
<
In
>
()(
return
::
pushmi
::
detail
::
out_from_fn
<
In
>
()(
std
::
move
(
out
),
std
::
move
(
out
),
::
pushmi
::
on_error
([](
auto
&
,
auto
&&
)
noexcept
{
::
pushmi
::
on_error
(
on_error_impl
{})
std
::
abort
();
})
);
);
}
}
};
};
...
...
folly/experimental/pushmi/examples/include/pool.h
View file @
492ce4ff
...
@@ -30,7 +30,7 @@ struct __pool_submit {
...
@@ -30,7 +30,7 @@ struct __pool_submit {
PUSHMI_TEMPLATE
(
class
TP
,
class
Out
)
PUSHMI_TEMPLATE
(
class
TP
,
class
Out
)
(
requires
Regular
<
TP
>
&&
Receiver
<
Out
>
)
(
requires
Regular
<
TP
>
&&
Receiver
<
Out
>
)
void
operator
()(
TP
at
,
Out
out
)
const
{
void
operator
()(
TP
at
,
Out
out
)
const
{
e
.
execute
([
e
=
this
->
e
,
at
=
std
::
move
(
at
),
out
=
std
::
move
(
out
)]()
mutable
{
e
.
execute
([
e
=
e
,
at
=
std
::
move
(
at
),
out
=
std
::
move
(
out
)]()
mutable
{
auto
tr
=
trampoline
();
auto
tr
=
trampoline
();
::
pushmi
::
submit
(
tr
,
std
::
move
(
at
),
std
::
move
(
out
));
::
pushmi
::
submit
(
tr
,
std
::
move
(
at
),
std
::
move
(
out
));
});
});
...
...
folly/experimental/pushmi/examples/include/reduce.h
View file @
492ce4ff
...
@@ -11,22 +11,41 @@
...
@@ -11,22 +11,41 @@
namespace
pushmi
{
namespace
pushmi
{
template
<
class
ExecutionPolicy
,
class
ForwardIt
,
class
T
,
class
BinaryOp
>
PUSHMI_INLINE_VAR
constexpr
struct
reduce_fn
{
T
reduce
(
private:
template
<
class
BinaryOp
>
struct
fn
{
BinaryOp
binary_op_
;
template
<
class
Acc
,
class
Cursor
>
void
operator
()(
Acc
&
acc
,
Cursor
cursor
)
const
{
acc
=
binary_op_
(
acc
,
*
cursor
);
}
};
struct
identity
{
template
<
class
T
>
auto
operator
()(
T
&&
t
)
const
{
return
(
T
&&
)
t
;
}
};
public:
template
<
class
ExecutionPolicy
,
class
ForwardIt
,
class
T
,
class
BinaryOp
>
T
operator
()(
ExecutionPolicy
&&
policy
,
ExecutionPolicy
&&
policy
,
ForwardIt
begin
,
ForwardIt
begin
,
ForwardIt
end
,
ForwardIt
end
,
T
init
,
T
init
,
BinaryOp
binary_op
)
{
BinaryOp
binary_op
)
const
{
return
operators
::
just
(
std
::
move
(
init
))
|
return
operators
::
just
(
std
::
move
(
init
))
|
operators
::
bulk
(
operators
::
bulk
(
[
binary_op
](
auto
&
acc
,
auto
cursor
){
acc
=
binary_op
(
acc
,
*
cursor
);
},
fn
<
BinaryOp
>
{
binary_op
},
begin
,
begin
,
end
,
end
,
policy
,
policy
,
[](
auto
&&
args
){
return
args
;
},
identity
{},
[](
auto
&&
acc
){
return
acc
;
})
|
identity
{}
)
|
operators
::
get
<
T
>
;
operators
::
get
<
T
>
;
}
}
}
reduce
{};
}
// namespace pushmi
}
// 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