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
3928c4e9
Commit
3928c4e9
authored
Jan 21, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UpdateRemove: Mutex/Cond instead of GMutex/GCond
parent
32799fef
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
22 deletions
+10
-22
UpdateGlue.cxx
src/UpdateGlue.cxx
+0
-1
UpdateRemove.cxx
src/UpdateRemove.cxx
+10
-18
UpdateRemove.hxx
src/UpdateRemove.hxx
+0
-3
No files found.
src/UpdateGlue.cxx
View file @
3928c4e9
...
...
@@ -182,5 +182,4 @@ void update_global_init(void)
void
update_global_finish
(
void
)
{
update_walk_global_finish
();
update_remove_global_finish
();
}
src/UpdateRemove.cxx
View file @
3928c4e9
...
...
@@ -22,6 +22,8 @@
#include "Playlist.hxx"
#include "Partition.hxx"
#include "GlobalEvents.hxx"
#include "thread/Mutex.hxx"
#include "thread/Cond.hxx"
#include "song.h"
#include "Main.hxx"
...
...
@@ -37,8 +39,8 @@
static
const
struct
song
*
removed_song
;
static
GMutex
*
remove_mutex
;
static
GCond
*
remove_cond
;
static
Mutex
remove_mutex
;
static
Cond
remove_cond
;
/**
* Safely remove a song from the database. This must be done in the
...
...
@@ -64,29 +66,19 @@ song_remove_event(void)
global_partition
->
DeleteSong
(
*
removed_song
);
/* clear "removed_song" and send signal to update thread */
g_mutex_lock
(
remove_mutex
);
remove_mutex
.
lock
(
);
removed_song
=
NULL
;
g_cond_signal
(
remove_cond
);
g_mutex_unlock
(
remove_mutex
);
remove_cond
.
signal
(
);
remove_mutex
.
unlock
(
);
}
void
update_remove_global_init
(
void
)
{
remove_mutex
=
g_mutex_new
();
remove_cond
=
g_cond_new
();
GlobalEvents
::
Register
(
GlobalEvents
::
DELETE
,
song_remove_event
);
}
void
update_remove_global_finish
(
void
)
{
g_mutex_free
(
remove_mutex
);
g_cond_free
(
remove_cond
);
}
void
update_remove_song
(
const
struct
song
*
song
)
{
assert
(
removed_song
==
NULL
);
...
...
@@ -95,10 +87,10 @@ update_remove_song(const struct song *song)
GlobalEvents
::
Emit
(
GlobalEvents
::
DELETE
);
g_mutex_lock
(
remove_mutex
);
remove_mutex
.
lock
(
);
while
(
removed_song
!=
NULL
)
g_cond_wait
(
remove_cond
,
remove_mutex
);
remove_cond
.
wait
(
remove_mutex
);
g_mutex_unlock
(
remove_mutex
);
remove_mutex
.
unlock
(
);
}
src/UpdateRemove.hxx
View file @
3928c4e9
...
...
@@ -27,9 +27,6 @@ struct song;
void
update_remove_global_init
(
void
);
void
update_remove_global_finish
(
void
);
/**
* Sends a signal to the main thread which will in turn remove the
* song: from the sticker database and from the playlist. This
...
...
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