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
a6ee6be9
Commit
a6ee6be9
authored
Jan 07, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TagPool: use the Mutex class instead of GStaticMutex
parent
47911f95
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
22 deletions
+13
-22
Tag.cxx
src/Tag.cxx
+10
-10
TagPool.cxx
src/TagPool.cxx
+1
-11
TagPool.hxx
src/TagPool.hxx
+2
-1
No files found.
src/Tag.cxx
View file @
a6ee6be9
...
...
@@ -145,9 +145,9 @@ static void tag_delete_item(struct tag *tag, unsigned idx)
assert
(
idx
<
tag
->
num_items
);
tag
->
num_items
--
;
g_static_mutex_lock
(
&
tag_pool_lock
);
tag_pool_lock
.
lock
(
);
tag_pool_put_item
(
tag
->
items
[
idx
]);
g_static_mutex_unlock
(
&
tag_pool_lock
);
tag_pool_lock
.
unlock
(
);
if
(
tag
->
num_items
-
idx
>
0
)
{
memmove
(
tag
->
items
+
idx
,
tag
->
items
+
idx
+
1
,
...
...
@@ -180,10 +180,10 @@ void tag_free(struct tag *tag)
assert
(
tag
!=
nullptr
);
g_static_mutex_lock
(
&
tag_pool_lock
);
tag_pool_lock
.
lock
(
);
for
(
i
=
tag
->
num_items
;
--
i
>=
0
;
)
tag_pool_put_item
(
tag
->
items
[
i
]);
g_static_mutex_unlock
(
&
tag_pool_lock
);
tag_pool_lock
.
unlock
(
);
if
(
tag
->
items
==
bulk
.
items
)
{
#ifndef NDEBUG
...
...
@@ -211,10 +211,10 @@ struct tag *tag_dup(const struct tag *tag)
?
(
struct
tag_item
**
)
g_malloc
(
items_size
(
tag
))
:
nullptr
;
g_static_mutex_lock
(
&
tag_pool_lock
);
tag_pool_lock
.
lock
(
);
for
(
unsigned
i
=
0
;
i
<
tag
->
num_items
;
i
++
)
ret
->
items
[
i
]
=
tag_pool_dup_item
(
tag
->
items
[
i
]);
g_static_mutex_unlock
(
&
tag_pool_lock
);
tag_pool_lock
.
unlock
(
);
return
ret
;
}
...
...
@@ -237,7 +237,7 @@ tag_merge(const struct tag *base, const struct tag *add)
?
(
struct
tag_item
**
)
g_malloc
(
items_size
(
ret
))
:
nullptr
;
g_static_mutex_lock
(
&
tag_pool_lock
);
tag_pool_lock
.
lock
(
);
/* copy all items from "add" */
...
...
@@ -252,7 +252,7 @@ tag_merge(const struct tag *base, const struct tag *add)
if
(
!
tag_has_type
(
add
,
base
->
items
[
i
]
->
type
))
ret
->
items
[
n
++
]
=
tag_pool_dup_item
(
base
->
items
[
i
]);
g_static_mutex_unlock
(
&
tag_pool_lock
);
tag_pool_lock
.
unlock
(
);
assert
(
n
<=
ret
->
num_items
);
...
...
@@ -487,9 +487,9 @@ tag_add_item_internal(struct tag *tag, enum tag_type type,
items_size
(
tag
)
-
sizeof
(
struct
tag_item
*
));
}
g_static_mutex_lock
(
&
tag_pool_lock
);
tag_pool_lock
.
lock
(
);
tag
->
items
[
i
]
=
tag_pool_get_item
(
type
,
value
,
len
);
g_static_mutex_unlock
(
&
tag_pool_lock
);
tag_pool_lock
.
unlock
(
);
g_free
(
p
);
}
...
...
src/TagPool.cxx
View file @
a6ee6be9
...
...
@@ -22,17 +22,7 @@
#include <assert.h>
#if GCC_CHECK_VERSION(4, 2)
/* workaround for a warning caused by G_STATIC_MUTEX_INIT */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#endif
GStaticMutex
tag_pool_lock
=
G_STATIC_MUTEX_INIT
;
#if GCC_CHECK_VERSION(4, 2)
#pragma GCC diagnostic pop
#endif
Mutex
tag_pool_lock
;
#define NUM_SLOTS 4096
...
...
src/TagPool.hxx
View file @
a6ee6be9
...
...
@@ -21,10 +21,11 @@
#define MPD_TAG_POOL_HXX
#include "tag.h"
#include "thread/Mutex.hxx"
#include <glib.h>
extern
GStatic
Mutex
tag_pool_lock
;
extern
Mutex
tag_pool_lock
;
struct
tag_item
;
...
...
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