Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Root
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
为了安全,强烈建议开启2FA双因子认证:User Settings -> Account -> Enable two-factor authentication!!!
Show more breadcrumbs
cxwx
Root
Commits
7f2b0e5d
Commit
7f2b0e5d
authored
7 years ago
by
Danilo Piparo
Browse files
Options
Downloads
Patches
Plain Diff
Clang format
parent
00d18057
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/imt/inc/ROOT/Future.hxx
+30
-18
30 additions, 18 deletions
core/imt/inc/ROOT/Future.hxx
with
30 additions
and
18 deletions
core/imt/inc/ROOT/Future.hxx
+
30
−
18
View file @
7f2b0e5d
...
@@ -38,13 +38,16 @@ class Future;
...
@@ -38,13 +38,16 @@ class Future;
namespace
Detail
{
namespace
Detail
{
template
<
typename
T
>
template
<
typename
T
>
class
FutureImpl
{
class
FutureImpl
{
template
<
typename
V
>
friend
class
Experimental
::
Future
;
template
<
typename
V
>
friend
class
Experimental
::
Future
;
protected:
protected:
using
TTaskGroup
=
Experimental
::
TTaskGroup
;
using
TTaskGroup
=
Experimental
::
TTaskGroup
;
std
::
future
<
T
>
fStdFut
;
std
::
future
<
T
>
fStdFut
;
std
::
unique_ptr
<
TTaskGroup
>
fTg
{
nullptr
};
std
::
unique_ptr
<
TTaskGroup
>
fTg
{
nullptr
};
FutureImpl
(
std
::
future
<
T
>
&&
fut
,
std
::
unique_ptr
<
TTaskGroup
>
&&
tg
)
:
fStdFut
(
std
::
move
(
fut
))
{
FutureImpl
(
std
::
future
<
T
>
&&
fut
,
std
::
unique_ptr
<
TTaskGroup
>
&&
tg
)
:
fStdFut
(
std
::
move
(
fut
))
{
fTg
=
std
::
move
(
tg
);
fTg
=
std
::
move
(
tg
);
};
};
FutureImpl
(){};
FutureImpl
(){};
...
@@ -53,20 +56,20 @@ protected:
...
@@ -53,20 +56,20 @@ protected:
FutureImpl
(
FutureImpl
<
T
>
&&
other
)
{
*
this
=
std
::
move
(
other
);
}
FutureImpl
(
FutureImpl
<
T
>
&&
other
)
{
*
this
=
std
::
move
(
other
);
}
FutureImpl
&
operator
=
(
std
::
future
<
T
>
&&
other
)
FutureImpl
&
operator
=
(
std
::
future
<
T
>
&&
other
)
{
fStdFut
=
std
::
move
(
other
);
}
{
fStdFut
=
std
::
move
(
other
);
}
FutureImpl
<
T
>
&
operator
=
(
FutureImpl
<
T
>
&&
other
)
=
default
;
FutureImpl
<
T
>
&
operator
=
(
FutureImpl
<
T
>
&&
other
)
=
default
;
public
:
public
:
FutureImpl
<
T
>
&
operator
=
(
FutureImpl
<
T
>
&
other
)
=
delete
;
FutureImpl
<
T
>
&
operator
=
(
FutureImpl
<
T
>
&
other
)
=
delete
;
FutureImpl
(
const
FutureImpl
<
T
>
&
other
)
=
delete
;
FutureImpl
(
const
FutureImpl
<
T
>
&
other
)
=
delete
;
void
wait
()
{
if
(
fTg
)
fTg
->
Wait
();
}
void
wait
()
{
if
(
fTg
)
fTg
->
Wait
();
}
bool
valid
()
const
{
return
fStdFut
.
valid
();
};
bool
valid
()
const
{
return
fStdFut
.
valid
();
};
};
};
...
@@ -78,13 +81,16 @@ namespace Experimental {
...
@@ -78,13 +81,16 @@ namespace Experimental {
/// A future class. It can wrap an std::future.
/// A future class. It can wrap an std::future.
template
<
typename
T
>
template
<
typename
T
>
class
Future
final
:
public
Detail
::
FutureImpl
<
T
>
{
class
Future
final
:
public
Detail
::
FutureImpl
<
T
>
{
template
<
class
Function
,
class
...
Args
>
template
<
class
Function
,
class
...
Args
>
friend
Future
<
typename
std
::
result_of
<
typename
std
::
decay
<
Function
>::
type
(
typename
std
::
decay
<
Args
>::
type
...)
>::
type
>
Async
(
Function
&&
f
,
Args
&&
...
args
);
friend
Future
<
typename
std
::
result_of
<
typename
std
::
decay
<
Function
>::
type
(
typename
std
::
decay
<
Args
>::
type
...)
>::
type
>
Async
(
Function
&&
f
,
Args
&&
...
args
);
private:
private:
Future
(
std
::
future
<
T
>
&&
fut
,
std
::
unique_ptr
<
TTaskGroup
>
&&
tg
)
Future
(
std
::
future
<
T
>
&&
fut
,
std
::
unique_ptr
<
TTaskGroup
>
&&
tg
)
:
Detail
::
FutureImpl
<
T
>
(
std
::
forward
<
std
::
future
<
T
>>
(
fut
),
std
::
move
(
tg
)){};
:
Detail
::
FutureImpl
<
T
>
(
std
::
forward
<
std
::
future
<
T
>>
(
fut
),
std
::
move
(
tg
)){};
public
:
public
:
Future
(
std
::
future
<
T
>
&&
fut
)
:
Detail
::
FutureImpl
<
T
>
(
std
::
forward
<
std
::
future
<
T
>>
(
fut
))
{};
Future
(
std
::
future
<
T
>
&&
fut
)
:
Detail
::
FutureImpl
<
T
>
(
std
::
forward
<
std
::
future
<
T
>>
(
fut
)){};
T
get
()
T
get
()
{
{
...
@@ -96,13 +102,16 @@ public:
...
@@ -96,13 +102,16 @@ public:
// Two specialisations, for void and T& as for std::future
// Two specialisations, for void and T& as for std::future
template
<
>
template
<
>
class
Future
<
void
>
final
:
public
Detail
::
FutureImpl
<
void
>
{
class
Future
<
void
>
final
:
public
Detail
::
FutureImpl
<
void
>
{
template
<
class
Function
,
class
...
Args
>
template
<
class
Function
,
class
...
Args
>
friend
Future
<
typename
std
::
result_of
<
typename
std
::
decay
<
Function
>::
type
(
typename
std
::
decay
<
Args
>::
type
...)
>::
type
>
Async
(
Function
&&
f
,
Args
&&
...
args
);
friend
Future
<
typename
std
::
result_of
<
typename
std
::
decay
<
Function
>::
type
(
typename
std
::
decay
<
Args
>::
type
...)
>::
type
>
Async
(
Function
&&
f
,
Args
&&
...
args
);
private:
private:
Future
(
std
::
future
<
void
>
&&
fut
,
std
::
unique_ptr
<
TTaskGroup
>
&&
tg
)
Future
(
std
::
future
<
void
>
&&
fut
,
std
::
unique_ptr
<
TTaskGroup
>
&&
tg
)
:
Detail
::
FutureImpl
<
void
>
(
std
::
forward
<
std
::
future
<
void
>>
(
fut
),
std
::
move
(
tg
)){};
:
Detail
::
FutureImpl
<
void
>
(
std
::
forward
<
std
::
future
<
void
>>
(
fut
),
std
::
move
(
tg
)){};
public
:
public
:
Future
(
std
::
future
<
void
>
&&
fut
)
:
Detail
::
FutureImpl
<
void
>
(
std
::
forward
<
std
::
future
<
void
>>
(
fut
))
{};
Future
(
std
::
future
<
void
>
&&
fut
)
:
Detail
::
FutureImpl
<
void
>
(
std
::
forward
<
std
::
future
<
void
>>
(
fut
)){};
void
get
()
void
get
()
{
{
...
@@ -113,13 +122,16 @@ public:
...
@@ -113,13 +122,16 @@ public:
template
<
typename
T
>
template
<
typename
T
>
class
Future
<
T
&>
final
:
public
Detail
::
FutureImpl
<
T
&>
{
class
Future
<
T
&>
final
:
public
Detail
::
FutureImpl
<
T
&>
{
template
<
class
Function
,
class
...
Args
>
template
<
class
Function
,
class
...
Args
>
friend
Future
<
typename
std
::
result_of
<
typename
std
::
decay
<
Function
>::
type
(
typename
std
::
decay
<
Args
>::
type
...)
>::
type
>
Async
(
Function
&&
f
,
Args
&&
...
args
);
friend
Future
<
typename
std
::
result_of
<
typename
std
::
decay
<
Function
>::
type
(
typename
std
::
decay
<
Args
>::
type
...)
>::
type
>
Async
(
Function
&&
f
,
Args
&&
...
args
);
private:
private:
Future
(
std
::
future
<
T
&>
&&
fut
,
std
::
unique_ptr
<
TTaskGroup
>
&&
tg
)
Future
(
std
::
future
<
T
&>
&&
fut
,
std
::
unique_ptr
<
TTaskGroup
>
&&
tg
)
:
Detail
::
FutureImpl
<
T
&>
(
std
::
forward
<
std
::
future
<
T
&>>
(
fut
),
std
::
move
(
tg
)){};
:
Detail
::
FutureImpl
<
T
&>
(
std
::
forward
<
std
::
future
<
T
&>>
(
fut
),
std
::
move
(
tg
)){};
public
:
public
:
Future
(
std
::
future
<
T
&>
&&
fut
)
:
Detail
::
FutureImpl
<
T
&>
(
std
::
forward
<
std
::
future
<
T
&>>
(
fut
))
{};
Future
(
std
::
future
<
T
&>
&&
fut
)
:
Detail
::
FutureImpl
<
T
&>
(
std
::
forward
<
std
::
future
<
T
&>>
(
fut
)){};
T
&
get
()
T
&
get
()
{
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment