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
73fd98b8
Commit
73fd98b8
authored
Jan 14, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/upnp/WorkQueue: use std::list instead of std::unordered_map
Reduce bloat.
parent
6cb72539
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
18 deletions
+6
-18
WorkQueue.hxx
src/db/upnp/WorkQueue.hxx
+6
-18
No files found.
src/db/upnp/WorkQueue.hxx
View file @
73fd98b8
...
...
@@ -28,7 +28,7 @@
#include <string>
#include <queue>
#include <
unordered_map
>
#include <
list
>
//#include "debuglog.h"
#define LOGINFO(X)
...
...
@@ -49,16 +49,6 @@
*/
template
<
class
T
>
class
WorkQueue
{
/**
* Store per-worker-thread data. Just an initialized timespec,
* and used at the moment.
*/
class
WQTData
{
public
:
WQTData
()
{
wstart
.
tv_sec
=
0
;
wstart
.
tv_nsec
=
0
;}
struct
timespec
wstart
;
};
// Configuration
const
std
::
string
name
;
const
size_t
high
;
...
...
@@ -69,9 +59,7 @@ class WorkQueue {
unsigned
n_workers_exited
;
bool
ok
;
// Per-thread data. The data is not used currently, this could be
// a set<pthread_t>
std
::
unordered_map
<
pthread_t
,
WQTData
>
threads
;
std
::
list
<
pthread_t
>
threads
;
// Synchronization
std
::
queue
<
T
>
queue
;
...
...
@@ -121,7 +109,7 @@ public:
name
.
c_str
(),
err
));
return
false
;
}
threads
.
insert
(
std
::
make_pair
(
thr
,
WQTData
())
);
threads
.
push_back
(
thr
);
}
return
true
;
}
...
...
@@ -226,9 +214,9 @@ public:
// Workers return (void*)1 if ok
while
(
!
threads
.
empty
())
{
void
*
status
;
auto
it
=
threads
.
begin
();
pthread_join
(
it
->
first
,
&
status
);
threads
.
erase
(
it
);
auto
thread
=
threads
.
front
();
pthread_join
(
thread
,
&
status
);
threads
.
pop_front
(
);
}
// Reset to start state.
...
...
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