Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
cf108c38
Commit
cf108c38
authored
4 years ago
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
win32/ComWorker: remove parameter passing from Async()
Parameters should better be captured. This removes some complexity from Async().
parent
90d97053
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
10 deletions
+5
-10
ComWorker.hxx
src/win32/ComWorker.hxx
+5
-10
No files found.
src/win32/ComWorker.hxx
View file @
cf108c38
...
...
@@ -65,24 +65,19 @@ public:
COMWorker
(
const
COMWorker
&
)
=
delete
;
COMWorker
&
operator
=
(
const
COMWorker
&
)
=
delete
;
template
<
typename
Function
,
typename
...
Args
>
auto
Async
(
Function
&&
function
,
Args
&&
...
args
)
{
using
R
=
std
::
invoke_result_t
<
std
::
decay_t
<
Function
>
,
std
::
decay_t
<
Args
>
...
>
;
template
<
typename
Function
>
auto
Async
(
Function
&&
function
)
{
using
R
=
std
::
invoke_result_t
<
std
::
decay_t
<
Function
>>
;
auto
promise
=
std
::
make_shared
<
Promise
<
R
>>
();
auto
future
=
promise
->
get_future
();
thread
.
Push
([
function
=
std
::
forward
<
Function
>
(
function
),
args
=
std
::
make_tuple
(
std
::
forward
<
Args
>
(
args
)...),
promise
=
std
::
move
(
promise
)]()
mutable
{
try
{
if
constexpr
(
std
::
is_void_v
<
R
>
)
{
std
::
apply
(
std
::
forward
<
Function
>
(
function
),
std
::
move
(
args
));
std
::
invoke
(
std
::
forward
<
Function
>
(
function
));
promise
->
set_value
();
}
else
{
promise
->
set_value
(
std
::
apply
(
std
::
forward
<
Function
>
(
function
),
std
::
move
(
args
)));
promise
->
set_value
(
std
::
invoke
(
std
::
forward
<
Function
>
(
function
)));
}
}
catch
(...)
{
promise
->
set_exception
(
std
::
current_exception
());
...
...
This diff is collapsed.
Click to expand it.
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