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
28128dc4
Commit
28128dc4
authored
Dec 28, 2008
by
Thomas Jansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tag & tag_pool: migrate from pthread to glib threads
parent
ce5c22f4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
11 deletions
+31
-11
main.c
src/main.c
+3
-0
tag.c
src/tag.c
+8
-8
tag_pool.c
src/tag_pool.c
+14
-1
tag_pool.h
src/tag_pool.h
+6
-2
No files found.
src/main.c
View file @
28128dc4
...
...
@@ -52,6 +52,7 @@
#include "os_compat.h"
#include "dirvec.h"
#include "songvec.h"
#include "tag_pool.h"
#ifdef ENABLE_ARCHIVE
#include "archive_list.h"
...
...
@@ -273,6 +274,7 @@ int main(int argc, char *argv[])
idle_init
();
dirvec_init
();
songvec_init
();
tag_pool_init
();
initConf
();
parseOptions
(
argc
,
argv
,
&
options
);
...
...
@@ -387,6 +389,7 @@ int main(int argc, char *argv[])
music_pipe_free
();
cleanUpPidFile
();
finishConf
();
tag_pool_deinit
();
songvec_deinit
();
dirvec_deinit
();
idle_deinit
();
...
...
src/tag.c
View file @
28128dc4
...
...
@@ -247,9 +247,9 @@ static void deleteItem(struct tag *tag, int idx)
assert
(
idx
<
tag
->
numOfItems
);
tag
->
numOfItems
--
;
pthread_mutex_lock
(
&
tag_pool_lock
);
g_mutex_lock
(
tag_pool_lock
);
tag_pool_put_item
(
tag
->
items
[
idx
]);
pthread_mutex_unlock
(
&
tag_pool_lock
);
g_mutex_unlock
(
tag_pool_lock
);
if
(
tag
->
numOfItems
-
idx
>
0
)
{
memmove
(
tag
->
items
+
idx
,
tag
->
items
+
idx
+
1
,
...
...
@@ -281,10 +281,10 @@ void tag_free(struct tag *tag)
{
int
i
;
pthread_mutex_lock
(
&
tag_pool_lock
);
g_mutex_lock
(
tag_pool_lock
);
for
(
i
=
tag
->
numOfItems
;
--
i
>=
0
;
)
tag_pool_put_item
(
tag
->
items
[
i
]);
pthread_mutex_unlock
(
&
tag_pool_lock
);
g_mutex_unlock
(
tag_pool_lock
);
if
(
tag
->
items
==
bulk
.
items
)
{
#ifndef NDEBUG
...
...
@@ -311,10 +311,10 @@ struct tag *tag_dup(const struct tag *tag)
ret
->
numOfItems
=
tag
->
numOfItems
;
ret
->
items
=
ret
->
numOfItems
>
0
?
g_malloc
(
items_size
(
tag
))
:
NULL
;
pthread_mutex_lock
(
&
tag_pool_lock
);
g_mutex_lock
(
tag_pool_lock
);
for
(
i
=
0
;
i
<
tag
->
numOfItems
;
i
++
)
ret
->
items
[
i
]
=
tag_pool_dup_item
(
tag
->
items
[
i
]);
pthread_mutex_unlock
(
&
tag_pool_lock
);
g_mutex_unlock
(
tag_pool_lock
);
return
ret
;
}
...
...
@@ -444,9 +444,9 @@ static void appendToTagItems(struct tag *tag, enum tag_type type,
items_size
(
tag
)
-
sizeof
(
struct
tag_item
*
));
}
pthread_mutex_lock
(
&
tag_pool_lock
);
g_mutex_lock
(
tag_pool_lock
);
tag
->
items
[
i
]
=
tag_pool_get_item
(
type
,
p
,
len
);
pthread_mutex_unlock
(
&
tag_pool_lock
);
g_mutex_unlock
(
tag_pool_lock
);
g_free
(
duplicated
);
}
...
...
src/tag_pool.c
View file @
28128dc4
...
...
@@ -21,7 +21,7 @@
#include <assert.h>
pthread_mutex_t
tag_pool_lock
=
PTHREAD_MUTEX_INITIALIZER
;
GMutex
*
tag_pool_lock
=
NULL
;
#define NUM_SLOTS 4096
...
...
@@ -80,6 +80,19 @@ static struct slot *slot_alloc(struct slot *next,
return
slot
;
}
void
tag_pool_init
(
void
)
{
g_assert
(
tag_pool_lock
==
NULL
);
tag_pool_lock
=
g_mutex_new
();
}
void
tag_pool_deinit
(
void
)
{
g_assert
(
tag_pool_lock
!=
NULL
);
g_mutex_free
(
tag_pool_lock
);
tag_pool_lock
=
NULL
;
}
struct
tag_item
*
tag_pool_get_item
(
enum
tag_type
type
,
const
char
*
value
,
int
length
)
{
...
...
src/tag_pool.h
View file @
28128dc4
...
...
@@ -21,12 +21,16 @@
#include "tag.h"
#include <
pthread
.h>
#include <
glib
.h>
extern
pthread_mutex_t
tag_pool_lock
;
extern
GMutex
*
tag_pool_lock
;
struct
tag_item
;
void
tag_pool_init
(
void
);
void
tag_pool_deinit
(
void
);
struct
tag_item
*
tag_pool_get_item
(
enum
tag_type
type
,
const
char
*
value
,
int
length
);
...
...
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