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
48bdd09f
Commit
48bdd09f
authored
Mar 07, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
win32/ComWorker: fold class COMWorkerThread into class COMWorker
parent
cf108c38
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
24 deletions
+20
-24
ComWorker.cxx
src/win32/ComWorker.cxx
+3
-1
ComWorker.hxx
src/win32/ComWorker.hxx
+17
-23
No files found.
src/win32/ComWorker.cxx
View file @
48bdd09f
...
...
@@ -21,7 +21,9 @@
#include "Com.hxx"
#include "thread/Name.hxx"
void
COMWorker
::
COMWorkerThread
::
Work
()
noexcept
{
void
COMWorker
::
Work
()
noexcept
{
SetThreadName
(
"COM Worker"
);
COM
com
{
true
};
while
(
true
)
{
...
...
src/win32/ComWorker.hxx
View file @
48bdd09f
...
...
@@ -30,27 +30,11 @@
// Worker thread for all COM operation
class
COMWorker
{
private
:
class
COMWorkerThread
:
public
Thread
{
public
:
COMWorkerThread
()
:
Thread
{
BIND_THIS_METHOD
(
Work
)}
{}
private
:
friend
class
COMWorker
;
void
Work
()
noexcept
;
void
Finish
()
noexcept
{
running_flag
.
clear
();
event
.
Set
();
}
void
Push
(
const
std
::
function
<
void
()
>
&
function
)
{
spsc_buffer
.
push
(
function
);
event
.
Set
();
}
Thread
thread
{
BIND_THIS_METHOD
(
Work
)};
boost
::
lockfree
::
spsc_queue
<
std
::
function
<
void
()
>>
spsc_buffer
{
32
};
std
::
atomic_flag
running_flag
=
true
;
WinEvent
event
{};
};
boost
::
lockfree
::
spsc_queue
<
std
::
function
<
void
()
>>
spsc_buffer
{
32
};
std
::
atomic_flag
running_flag
=
true
;
WinEvent
event
{};
public
:
COMWorker
()
{
...
...
@@ -58,7 +42,7 @@ public:
}
~
COMWorker
()
noexcept
{
thread
.
Finish
();
Finish
();
thread
.
Join
();
}
...
...
@@ -70,7 +54,7 @@ public:
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
),
Push
([
function
=
std
::
forward
<
Function
>
(
function
),
promise
=
std
::
move
(
promise
)]()
mutable
{
try
{
if
constexpr
(
std
::
is_void_v
<
R
>
)
{
...
...
@@ -87,7 +71,17 @@ public:
}
private
:
COMWorkerThread
thread
;
void
Finish
()
noexcept
{
running_flag
.
clear
();
event
.
Set
();
}
void
Push
(
const
std
::
function
<
void
()
>
&
function
)
{
spsc_buffer
.
push
(
function
);
event
.
Set
();
}
void
Work
()
noexcept
;
};
#endif
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