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
ff57e8ff
Commit
ff57e8ff
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
Cleanup any_time_executor and any_time_executor_ref
fbshipit-source-id: 57b9cddb7f3a2072bbf9335c3230a6f9c0219e77
parent
85207e0f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
124 additions
and
86 deletions
+124
-86
folly/experimental/pushmi/include/pushmi.h
folly/experimental/pushmi/include/pushmi.h
+62
-43
folly/experimental/pushmi/include/pushmi/executor.h
folly/experimental/pushmi/include/pushmi/executor.h
+61
-41
folly/experimental/pushmi/include/pushmi/forwards.h
folly/experimental/pushmi/include/pushmi/forwards.h
+1
-2
No files found.
folly/experimental/pushmi/include/pushmi.h
View file @
ff57e8ff
...
...
@@ -1282,8 +1282,7 @@ class flow_single_deferred;
template
<
class
E
=
std
::
exception_ptr
,
class
TP
=
std
::
chrono
::
system_clock
::
time_point
,
int
i
=
0
>
class
TP
=
std
::
chrono
::
system_clock
::
time_point
>
struct
any_time_executor_ref
;
namespace
operators
{}
...
...
@@ -3854,33 +3853,35 @@ time_single_deferred(Data, DSF, DNF) -> time_single_deferred<Data, DSF, DNF>;
//#include "time_single_deferred.h"
namespace
pushmi
{
namespace
detail
{
template
<
class
T
,
template
<
class
...
>
class
C
>
using
not_is_t
=
std
::
enable_if_t
<!
is_v
<
std
::
decay_t
<
T
>
,
C
>
,
std
::
decay_t
<
T
>>
;
template
<
class
T
>
using
not_any_time_executor_ref_t
=
not_is_t
<
T
,
any_time_executor_ref
>
;
}
// namespace detail
template
<
class
E
,
class
TP
>
struct
any_time_executor_ref
_base
{
struct
any_time_executor_ref
{
private:
friend
any_time_executor_ref
<
E
,
TP
,
0
>
;
friend
any_time_executor_ref
<
E
,
TP
,
1
>
;
using
Other
=
any_time_executor_ref
<
E
,
TP
,
1
>
;
using
This
=
any_time_executor_ref
;
void
*
pobj_
;
struct
vtable
{
TP
(
*
now_
)(
void
*
);
void
(
*
submit_
)(
void
*
,
TP
,
void
*
);
}
const
*
vptr_
;
template
<
class
T
,
class
U
=
std
::
decay_t
<
T
>
>
using
wrapped_t
=
std
::
enable_if_t
<!
std
::
is_base_of
<
any_time_executor_ref_base
,
U
>::
value
,
U
>
;
template
<
class
T
>
using
wrapped_t
=
detail
::
not_any_time_executor_ref_t
<
T
>
;
public:
using
properties
=
property_set
<
is_time
<>
,
is_single
<>>
;
any_time_executor_ref
_base
()
=
delete
;
any_time_executor_ref
_base
(
const
any_time_executor_ref_base
&
)
=
default
;
any_time_executor_ref
()
=
delete
;
any_time_executor_ref
(
const
any_time_executor_ref
&
)
=
default
;
PUSHMI_TEMPLATE
(
class
Wrapped
)
(
requires
TimeSender
<
wrapped_t
<
Wrapped
>
,
is_single
<>>
)
// (requires TimeSenderTo<wrapped_t<Wrapped>, single<
Other
, E>>)
any_time_executor_ref
_base
(
Wrapped
&
w
)
{
// (requires TimeSenderTo<wrapped_t<Wrapped>, single<
This
, E>>)
any_time_executor_ref
(
Wrapped
&
w
)
{
// This can't be a requirement because it asks if submit(w, now(w), single<T,E>)
// is well-formed (where T is an alias for any_time_executor_ref). If w
// has a submit that is constrained with SingleReceiver<single<T, E>, T'&, E'>, that
...
...
@@ -3888,9 +3889,9 @@ public:
// ask whether T'& is convertible to T. That brings us right back to this
// constructor. Constraint recursion!
static_assert
(
TimeSenderTo
<
Wrapped
,
single
<
Other
,
E
>>
,
TimeSenderTo
<
Wrapped
,
single
<
This
,
E
>>
,
"Expecting to be passed a TimeSender that can send to a SingleReceiver"
" that accpets a value of type
Other
and an error of type E"
);
" that accpets a value of type
This
and an error of type E"
);
struct
s
{
static
TP
now
(
void
*
pobj
)
{
return
::
pushmi
::
now
(
*
static_cast
<
Wrapped
*>
(
pobj
));
...
...
@@ -3899,7 +3900,7 @@ public:
return
::
pushmi
::
submit
(
*
static_cast
<
Wrapped
*>
(
pobj
),
tp
,
std
::
move
(
*
static_cast
<
single
<
Other
,
E
>*>
(
s
)));
std
::
move
(
*
static_cast
<
single
<
This
,
E
>*>
(
s
)));
}
};
static
const
vtable
vtbl
{
s
::
now
,
s
::
submit
};
...
...
@@ -3912,35 +3913,29 @@ public:
template
<
class
SingleReceiver
>
void
submit
(
TP
tp
,
SingleReceiver
&&
sa
)
{
// static_assert(
// ConvertibleTo<SingleReceiver, any_single<
Other
, E>>,
// ConvertibleTo<SingleReceiver, any_single<
This
, E>>,
// "requires any_single<any_time_executor_ref<E, TP>, E>");
any_single
<
Other
,
E
>
s
{(
SingleReceiver
&&
)
sa
};
any_single
<
This
,
E
>
s
{(
SingleReceiver
&&
)
sa
};
vptr_
->
submit_
(
pobj_
,
tp
,
&
s
);
}
};
}
// namespace detail
template
<
class
E
,
class
TP
,
int
i
>
struct
any_time_executor_ref
:
detail
::
any_time_executor_ref_base
<
E
,
TP
>
{
using
detail
::
any_time_executor_ref_base
<
E
,
TP
>::
any_time_executor_ref_base
;
any_time_executor_ref
(
const
detail
::
any_time_executor_ref_base
<
E
,
TP
>&
o
)
:
detail
::
any_time_executor_ref_base
<
E
,
TP
>
(
o
)
{}
};
////////////////////////////////////////////////////////////////////////////////
// make_any_time_executor_ref
template
<
class
E
=
std
::
exception_ptr
,
class
TP
=
std
::
chrono
::
system_clock
::
time_point
>
auto
make_any_time_executor_ref
()
->
any_time_executor_ref
<
E
,
TP
>
{
return
any_time_executor_ref
<
E
,
TP
,
0
>
{};
auto
make_any_time_executor_ref
()
{
return
any_time_executor_ref
<
E
,
TP
>
{};
}
template
<
PUSHMI_TEMPLATE
(
class
E
=
std
::
exception_ptr
,
class
TP
=
std
::
chrono
::
system_clock
::
time_point
,
class
Wrapped
>
auto
make_any_time_executor_ref
(
Wrapped
w
)
->
any_time_executor_ref
<
E
,
TP
>
{
return
any_time_executor_ref
<
E
,
TP
,
0
>
{
std
::
move
(
w
)};
class
Wrapped
)
(
requires
TimeSender
<
detail
::
not_any_time_executor_ref_t
<
Wrapped
>
,
is_single
<>>
)
auto
make_any_time_executor_ref
(
Wrapped
&
w
)
{
return
any_time_executor_ref
<
E
,
TP
>
{
w
};
}
////////////////////////////////////////////////////////////////////////////////
...
...
@@ -3951,19 +3946,30 @@ any_time_executor_ref() ->
std
::
exception_ptr
,
std
::
chrono
::
system_clock
::
time_point
>
;
template
<
class
Wrapped
>
any_time_executor_ref
(
Wrapped
)
->
PUSHMI_TEMPLATE
(
class
Wrapped
)
(
requires
TimeSender
<
detail
::
not_any_time_executor_ref_t
<
Wrapped
>
,
is_single
<>>
)
any_time_executor_ref
(
Wrapped
&
)
->
any_time_executor_ref
<
std
::
exception_ptr
,
std
::
chrono
::
system_clock
::
time_point
>
;
#endif
namespace
detail
{
template
<
class
E
,
class
TP
>
struct
any_time_executor
:
any_time_single_deferred
<
any_time_executor_ref
<
E
,
TP
>
,
E
,
TP
>
{
using
any_time_executor_base
=
any_time_single_deferred
<
any_time_executor_ref
<
E
,
TP
>
,
E
,
TP
>
;
template
<
class
T
,
class
E
,
class
TP
>
using
not_any_time_executor
=
std
::
enable_if_t
<
!
std
::
is_base_of
<
any_time_executor_base
<
E
,
TP
>
,
std
::
decay_t
<
T
>>::
value
,
std
::
decay_t
<
T
>>
;
}
// namespace detail
template
<
class
E
,
class
TP
>
struct
any_time_executor
:
detail
::
any_time_executor_base
<
E
,
TP
>
{
constexpr
any_time_executor
()
=
default
;
using
any_time_single_deferred
<
any_time_executor_ref
<
E
,
TP
>
,
E
,
TP
>::
any_time_single_deferred
;
using
detail
::
any_time_executor_base
<
E
,
TP
>::
any_time_executor_base
;
};
////////////////////////////////////////////////////////////////////////////////
...
...
@@ -3975,10 +3981,13 @@ auto make_any_time_executor() -> any_time_executor<E, TP> {
return
any_time_executor
<
E
,
TP
>
{};
}
template
<
PUSHMI_TEMPLATE
(
class
E
=
std
::
exception_ptr
,
class
TP
=
std
::
chrono
::
system_clock
::
time_point
,
class
Wrapped
>
class
Wrapped
)
(
requires
TimeSenderTo
<
detail
::
not_any_time_executor
<
Wrapped
,
E
,
TP
>
,
single
<
any_time_executor_ref
<
E
,
TP
>
,
E
>>
)
auto
make_any_time_executor
(
Wrapped
w
)
->
any_time_executor
<
E
,
TP
>
{
return
any_time_executor
<
E
,
TP
>
{
std
::
move
(
w
)};
}
...
...
@@ -3991,7 +4000,17 @@ any_time_executor() ->
std
::
exception_ptr
,
std
::
chrono
::
system_clock
::
time_point
>
;
template
<
class
Wrapped
>
PUSHMI_TEMPLATE
(
class
Wrapped
)
(
requires
TimeSenderTo
<
detail
::
not_any_time_executor
<
Wrapped
,
std
::
exception_ptr
,
std
::
chrono
::
system_clock
::
time_point
>
,
single
<
any_time_executor_ref
<
std
::
exception_ptr
,
std
::
chrono
::
system_clock
::
time_point
>
,
std
::
exception_ptr
>>
)
any_time_executor
(
Wrapped
)
->
any_time_executor
<
std
::
exception_ptr
,
...
...
folly/experimental/pushmi/include/pushmi/executor.h
View file @
ff57e8ff
...
...
@@ -9,33 +9,35 @@
#include "time_single_deferred.h"
namespace
pushmi
{
namespace
detail
{
template
<
class
T
,
template
<
class
...
>
class
C
>
using
not_is_t
=
std
::
enable_if_t
<!
is_v
<
std
::
decay_t
<
T
>
,
C
>
,
std
::
decay_t
<
T
>>
;
template
<
class
T
>
using
not_any_time_executor_ref_t
=
not_is_t
<
T
,
any_time_executor_ref
>
;
}
// namespace detail
template
<
class
E
,
class
TP
>
struct
any_time_executor_ref
_base
{
struct
any_time_executor_ref
{
private:
friend
any_time_executor_ref
<
E
,
TP
,
0
>
;
friend
any_time_executor_ref
<
E
,
TP
,
1
>
;
using
Other
=
any_time_executor_ref
<
E
,
TP
,
1
>
;
using
This
=
any_time_executor_ref
;
void
*
pobj_
;
struct
vtable
{
TP
(
*
now_
)(
void
*
);
void
(
*
submit_
)(
void
*
,
TP
,
void
*
);
}
const
*
vptr_
;
template
<
class
T
,
class
U
=
std
::
decay_t
<
T
>
>
using
wrapped_t
=
std
::
enable_if_t
<!
std
::
is_base_of
<
any_time_executor_ref_base
,
U
>::
value
,
U
>
;
template
<
class
T
>
using
wrapped_t
=
detail
::
not_any_time_executor_ref_t
<
T
>
;
public:
using
properties
=
property_set
<
is_time
<>
,
is_single
<>>
;
any_time_executor_ref
_base
()
=
delete
;
any_time_executor_ref
_base
(
const
any_time_executor_ref_base
&
)
=
default
;
any_time_executor_ref
()
=
delete
;
any_time_executor_ref
(
const
any_time_executor_ref
&
)
=
default
;
PUSHMI_TEMPLATE
(
class
Wrapped
)
(
requires
TimeSender
<
wrapped_t
<
Wrapped
>
,
is_single
<>>
)
// (requires TimeSenderTo<wrapped_t<Wrapped>, single<
Other
, E>>)
any_time_executor_ref
_base
(
Wrapped
&
w
)
{
// (requires TimeSenderTo<wrapped_t<Wrapped>, single<
This
, E>>)
any_time_executor_ref
(
Wrapped
&
w
)
{
// This can't be a requirement because it asks if submit(w, now(w), single<T,E>)
// is well-formed (where T is an alias for any_time_executor_ref). If w
// has a submit that is constrained with SingleReceiver<single<T, E>, T'&, E'>, that
...
...
@@ -43,9 +45,9 @@ public:
// ask whether T'& is convertible to T. That brings us right back to this
// constructor. Constraint recursion!
static_assert
(
TimeSenderTo
<
Wrapped
,
single
<
Other
,
E
>>
,
TimeSenderTo
<
Wrapped
,
single
<
This
,
E
>>
,
"Expecting to be passed a TimeSender that can send to a SingleReceiver"
" that accpets a value of type
Other
and an error of type E"
);
" that accpets a value of type
This
and an error of type E"
);
struct
s
{
static
TP
now
(
void
*
pobj
)
{
return
::
pushmi
::
now
(
*
static_cast
<
Wrapped
*>
(
pobj
));
...
...
@@ -54,7 +56,7 @@ public:
return
::
pushmi
::
submit
(
*
static_cast
<
Wrapped
*>
(
pobj
),
tp
,
std
::
move
(
*
static_cast
<
single
<
Other
,
E
>*>
(
s
)));
std
::
move
(
*
static_cast
<
single
<
This
,
E
>*>
(
s
)));
}
};
static
const
vtable
vtbl
{
s
::
now
,
s
::
submit
};
...
...
@@ -67,35 +69,29 @@ public:
template
<
class
SingleReceiver
>
void
submit
(
TP
tp
,
SingleReceiver
&&
sa
)
{
// static_assert(
// ConvertibleTo<SingleReceiver, any_single<
Other
, E>>,
// ConvertibleTo<SingleReceiver, any_single<
This
, E>>,
// "requires any_single<any_time_executor_ref<E, TP>, E>");
any_single
<
Other
,
E
>
s
{(
SingleReceiver
&&
)
sa
};
any_single
<
This
,
E
>
s
{(
SingleReceiver
&&
)
sa
};
vptr_
->
submit_
(
pobj_
,
tp
,
&
s
);
}
};
}
// namespace detail
template
<
class
E
,
class
TP
,
int
i
>
struct
any_time_executor_ref
:
detail
::
any_time_executor_ref_base
<
E
,
TP
>
{
using
detail
::
any_time_executor_ref_base
<
E
,
TP
>::
any_time_executor_ref_base
;
any_time_executor_ref
(
const
detail
::
any_time_executor_ref_base
<
E
,
TP
>&
o
)
:
detail
::
any_time_executor_ref_base
<
E
,
TP
>
(
o
)
{}
};
////////////////////////////////////////////////////////////////////////////////
// make_any_time_executor_ref
template
<
class
E
=
std
::
exception_ptr
,
class
TP
=
std
::
chrono
::
system_clock
::
time_point
>
auto
make_any_time_executor_ref
()
->
any_time_executor_ref
<
E
,
TP
>
{
return
any_time_executor_ref
<
E
,
TP
,
0
>
{};
auto
make_any_time_executor_ref
()
{
return
any_time_executor_ref
<
E
,
TP
>
{};
}
template
<
PUSHMI_TEMPLATE
(
class
E
=
std
::
exception_ptr
,
class
TP
=
std
::
chrono
::
system_clock
::
time_point
,
class
Wrapped
>
auto
make_any_time_executor_ref
(
Wrapped
w
)
->
any_time_executor_ref
<
E
,
TP
>
{
return
any_time_executor_ref
<
E
,
TP
,
0
>
{
std
::
move
(
w
)};
class
Wrapped
)
(
requires
TimeSender
<
detail
::
not_any_time_executor_ref_t
<
Wrapped
>
,
is_single
<>>
)
auto
make_any_time_executor_ref
(
Wrapped
&
w
)
{
return
any_time_executor_ref
<
E
,
TP
>
{
w
};
}
////////////////////////////////////////////////////////////////////////////////
...
...
@@ -106,19 +102,30 @@ any_time_executor_ref() ->
std
::
exception_ptr
,
std
::
chrono
::
system_clock
::
time_point
>
;
template
<
class
Wrapped
>
any_time_executor_ref
(
Wrapped
)
->
PUSHMI_TEMPLATE
(
class
Wrapped
)
(
requires
TimeSender
<
detail
::
not_any_time_executor_ref_t
<
Wrapped
>
,
is_single
<>>
)
any_time_executor_ref
(
Wrapped
&
)
->
any_time_executor_ref
<
std
::
exception_ptr
,
std
::
chrono
::
system_clock
::
time_point
>
;
#endif
namespace
detail
{
template
<
class
E
,
class
TP
>
struct
any_time_executor
:
any_time_single_deferred
<
any_time_executor_ref
<
E
,
TP
>
,
E
,
TP
>
{
using
any_time_executor_base
=
any_time_single_deferred
<
any_time_executor_ref
<
E
,
TP
>
,
E
,
TP
>
;
template
<
class
T
,
class
E
,
class
TP
>
using
not_any_time_executor
=
std
::
enable_if_t
<
!
std
::
is_base_of
<
any_time_executor_base
<
E
,
TP
>
,
std
::
decay_t
<
T
>>::
value
,
std
::
decay_t
<
T
>>
;
}
// namespace detail
template
<
class
E
,
class
TP
>
struct
any_time_executor
:
detail
::
any_time_executor_base
<
E
,
TP
>
{
constexpr
any_time_executor
()
=
default
;
using
any_time_single_deferred
<
any_time_executor_ref
<
E
,
TP
>
,
E
,
TP
>::
any_time_single_deferred
;
using
detail
::
any_time_executor_base
<
E
,
TP
>::
any_time_executor_base
;
};
////////////////////////////////////////////////////////////////////////////////
...
...
@@ -130,10 +137,13 @@ auto make_any_time_executor() -> any_time_executor<E, TP> {
return
any_time_executor
<
E
,
TP
>
{};
}
template
<
PUSHMI_TEMPLATE
(
class
E
=
std
::
exception_ptr
,
class
TP
=
std
::
chrono
::
system_clock
::
time_point
,
class
Wrapped
>
class
Wrapped
)
(
requires
TimeSenderTo
<
detail
::
not_any_time_executor
<
Wrapped
,
E
,
TP
>
,
single
<
any_time_executor_ref
<
E
,
TP
>
,
E
>>
)
auto
make_any_time_executor
(
Wrapped
w
)
->
any_time_executor
<
E
,
TP
>
{
return
any_time_executor
<
E
,
TP
>
{
std
::
move
(
w
)};
}
...
...
@@ -146,7 +156,17 @@ any_time_executor() ->
std
::
exception_ptr
,
std
::
chrono
::
system_clock
::
time_point
>
;
template
<
class
Wrapped
>
PUSHMI_TEMPLATE
(
class
Wrapped
)
(
requires
TimeSenderTo
<
detail
::
not_any_time_executor
<
Wrapped
,
std
::
exception_ptr
,
std
::
chrono
::
system_clock
::
time_point
>
,
single
<
any_time_executor_ref
<
std
::
exception_ptr
,
std
::
chrono
::
system_clock
::
time_point
>
,
std
::
exception_ptr
>>
)
any_time_executor
(
Wrapped
)
->
any_time_executor
<
std
::
exception_ptr
,
...
...
folly/experimental/pushmi/include/pushmi/forwards.h
View file @
ff57e8ff
...
...
@@ -70,8 +70,7 @@ class flow_single_deferred;
template
<
class
E
=
std
::
exception_ptr
,
class
TP
=
std
::
chrono
::
system_clock
::
time_point
,
int
i
=
0
>
class
TP
=
std
::
chrono
::
system_clock
::
time_point
>
struct
any_time_executor_ref
;
namespace
operators
{}
...
...
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