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
8332a704
Commit
8332a704
authored
Dec 28, 2008
by
Thomas Jansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
idle: migrate from pthread to glib threads
parent
5e3dc694
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
6 deletions
+35
-6
idle.c
src/idle.c
+21
-6
idle.h
src/idle.h
+12
-0
main.c
src/main.c
+2
-0
No files found.
src/idle.c
View file @
8332a704
...
...
@@ -25,10 +25,10 @@
#include "main_notify.h"
#include <assert.h>
#include <
pthread
.h>
#include <
glib
.h>
static
unsigned
idle_flags
;
static
pthread_mutex_t
idle_mutex
=
PTHREAD_MUTEX_INITIALIZER
;
static
GMutex
*
idle_mutex
=
NULL
;
static
const
char
*
const
idle_names
[]
=
{
"database"
,
...
...
@@ -43,13 +43,28 @@ static const char *const idle_names[] = {
};
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
)
{
assert
(
flags
!=
0
);
pthread_mutex_lock
(
&
idle_mutex
);
g_mutex_lock
(
idle_mutex
);
idle_flags
|=
flags
;
pthread_mutex_unlock
(
&
idle_mutex
);
g_mutex_unlock
(
idle_mutex
);
wakeup_main_task
();
}
...
...
@@ -59,10 +74,10 @@ idle_get(void)
{
unsigned
flags
;
pthread_mutex_lock
(
&
idle_mutex
);
g_mutex_lock
(
idle_mutex
);
flags
=
idle_flags
;
idle_flags
=
0
;
pthread_mutex_unlock
(
&
idle_mutex
);
g_mutex_unlock
(
idle_mutex
);
return
flags
;
}
...
...
src/idle.h
View file @
8332a704
...
...
@@ -49,6 +49,18 @@ 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
* clients.
*/
...
...
src/main.c
View file @
8332a704
...
...
@@ -268,6 +268,7 @@ int main(int argc, char *argv[])
/* enable GLib's thread safety code */
g_thread_init
(
NULL
);
idle_init
();
initConf
();
parseOptions
(
argc
,
argv
,
&
options
);
...
...
@@ -382,6 +383,7 @@ int main(int argc, char *argv[])
music_pipe_free
();
cleanUpPidFile
();
finishConf
();
idle_deinit
();
close_log_files
();
return
EXIT_SUCCESS
;
...
...
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