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
36c814d2
Commit
36c814d2
authored
Jan 16, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Idle: use std::atomic instead of GMutex
parent
d769b74d
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5 additions
and
44 deletions
+5
-44
ClientMessage.cxx
src/ClientMessage.cxx
+0
-1
Idle.cxx
src/Idle.cxx
+5
-29
Idle.hxx
src/Idle.hxx
+0
-12
Main.cxx
src/Main.cxx
+0
-2
No files found.
src/ClientMessage.cxx
View file @
36c814d2
...
@@ -19,7 +19,6 @@
...
@@ -19,7 +19,6 @@
#include "ClientMessage.hxx"
#include "ClientMessage.hxx"
#include <assert.h>
#include <glib.h>
#include <glib.h>
G_GNUC_PURE
G_GNUC_PURE
...
...
src/Idle.cxx
View file @
36c814d2
...
@@ -26,11 +26,11 @@
...
@@ -26,11 +26,11 @@
#include "Idle.hxx"
#include "Idle.hxx"
#include "GlobalEvents.hxx"
#include "GlobalEvents.hxx"
#include <atomic>
#include <assert.h>
#include <assert.h>
#include <glib.h>
static
unsigned
idle_flags
;
static
std
::
atomic_uint
idle_flags
;
static
GMutex
*
idle_mutex
=
NULL
;
static
const
char
*
const
idle_names
[]
=
{
static
const
char
*
const
idle_names
[]
=
{
"database"
,
"database"
,
...
@@ -44,32 +44,15 @@ static const char *const idle_names[] = {
...
@@ -44,32 +44,15 @@ static const char *const idle_names[] = {
"update"
,
"update"
,
"subscription"
,
"subscription"
,
"message"
,
"message"
,
NULL
nullptr
};
};
void
void
idle_init
(
void
)
{
g_assert
(
idle_mutex
==
NULL
);
idle_mutex
=
g_mutex_new
();
}
void
idle_deinit
(
void
)
{
g_assert
(
idle_mutex
!=
NULL
);
g_mutex_free
(
idle_mutex
);
idle_mutex
=
NULL
;
}
void
idle_add
(
unsigned
flags
)
idle_add
(
unsigned
flags
)
{
{
assert
(
flags
!=
0
);
assert
(
flags
!=
0
);
g_mutex_lock
(
idle_mutex
);
idle_flags
|=
flags
;
idle_flags
|=
flags
;
g_mutex_unlock
(
idle_mutex
);
GlobalEvents
::
Emit
(
GlobalEvents
::
IDLE
);
GlobalEvents
::
Emit
(
GlobalEvents
::
IDLE
);
}
}
...
@@ -77,14 +60,7 @@ idle_add(unsigned flags)
...
@@ -77,14 +60,7 @@ idle_add(unsigned flags)
unsigned
unsigned
idle_get
(
void
)
idle_get
(
void
)
{
{
unsigned
flags
;
return
idle_flags
.
fetch_and
(
0
);
g_mutex_lock
(
idle_mutex
);
flags
=
idle_flags
;
idle_flags
=
0
;
g_mutex_unlock
(
idle_mutex
);
return
flags
;
}
}
const
char
*
const
*
const
char
*
const
*
...
...
src/Idle.hxx
View file @
36c814d2
...
@@ -62,18 +62,6 @@ enum {
...
@@ -62,18 +62,6 @@ enum {
};
};
/**
/**
* Initialize the mutex
*/
void
idle_init
(
void
);
/**
* Destroy the mutex
*/
void
idle_deinit
(
void
);
/**
* Adds idle flag (with bitwise "or") and queues notifications to all
* Adds idle flag (with bitwise "or") and queues notifications to all
* clients.
* clients.
*/
*/
...
...
src/Main.cxx
View file @
36c814d2
...
@@ -375,7 +375,6 @@ int mpd_main(int argc, char *argv[])
...
@@ -375,7 +375,6 @@ int mpd_main(int argc, char *argv[])
io_thread_init
();
io_thread_init
();
winsock_init
();
winsock_init
();
idle_init
();
config_global_init
();
config_global_init
();
success
=
parse_cmdline
(
argc
,
argv
,
&
options
,
&
error
);
success
=
parse_cmdline
(
argc
,
argv
,
&
options
,
&
error
);
...
@@ -565,7 +564,6 @@ int mpd_main(int argc, char *argv[])
...
@@ -565,7 +564,6 @@ int mpd_main(int argc, char *argv[])
archive_plugin_deinit_all
();
archive_plugin_deinit_all
();
#endif
#endif
config_global_finish
();
config_global_finish
();
idle_deinit
();
stats_global_finish
();
stats_global_finish
();
io_thread_deinit
();
io_thread_deinit
();
daemonize_finish
();
daemonize_finish
();
...
...
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