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
770b1405
Commit
770b1405
authored
Sep 24, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
notify: declare "struct notify"
"struct notify" is the same as the "Notify" typedef. It can be forward-declared and has a lower case name.
parent
35216db8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
13 deletions
+13
-13
notify.c
src/notify.c
+6
-6
notify.h
src/notify.h
+7
-7
No files found.
src/notify.c
View file @
770b1405
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
#include "notify.h"
#include "notify.h"
int
notify_init
(
N
otify
*
notify
)
int
notify_init
(
struct
n
otify
*
notify
)
{
{
int
ret
;
int
ret
;
...
@@ -37,30 +37,30 @@ int notify_init(Notify *notify)
...
@@ -37,30 +37,30 @@ int notify_init(Notify *notify)
return
0
;
return
0
;
}
}
void
notify_enter
(
N
otify
*
notify
)
void
notify_enter
(
struct
n
otify
*
notify
)
{
{
pthread_mutex_lock
(
&
notify
->
mutex
);
pthread_mutex_lock
(
&
notify
->
mutex
);
}
}
void
notify_leave
(
N
otify
*
notify
)
void
notify_leave
(
struct
n
otify
*
notify
)
{
{
pthread_mutex_unlock
(
&
notify
->
mutex
);
pthread_mutex_unlock
(
&
notify
->
mutex
);
}
}
void
notify_wait
(
N
otify
*
notify
)
void
notify_wait
(
struct
n
otify
*
notify
)
{
{
if
(
!
notify
->
pending
)
if
(
!
notify
->
pending
)
pthread_cond_wait
(
&
notify
->
cond
,
&
notify
->
mutex
);
pthread_cond_wait
(
&
notify
->
cond
,
&
notify
->
mutex
);
notify
->
pending
=
0
;
notify
->
pending
=
0
;
}
}
void
notify_signal
(
N
otify
*
notify
)
void
notify_signal
(
struct
n
otify
*
notify
)
{
{
notify
->
pending
=
1
;
notify
->
pending
=
1
;
pthread_cond_signal
(
&
notify
->
cond
);
pthread_cond_signal
(
&
notify
->
cond
);
}
}
void
notify_signal_sync
(
N
otify
*
notify
)
void
notify_signal_sync
(
struct
n
otify
*
notify
)
{
{
pthread_mutex_lock
(
&
notify
->
mutex
);
pthread_mutex_lock
(
&
notify
->
mutex
);
notify_signal
(
notify
);
notify_signal
(
notify
);
...
...
src/notify.h
View file @
770b1405
...
@@ -21,40 +21,40 @@
...
@@ -21,40 +21,40 @@
#include "os_compat.h"
#include "os_compat.h"
typedef
struct
_N
otify
{
typedef
struct
n
otify
{
pthread_mutex_t
mutex
;
pthread_mutex_t
mutex
;
pthread_cond_t
cond
;
pthread_cond_t
cond
;
int
pending
;
int
pending
;
}
Notify
;
}
Notify
;
int
notify_init
(
N
otify
*
notify
);
int
notify_init
(
struct
n
otify
*
notify
);
/**
/**
* The thread which shall be notified by this object must call this
* The thread which shall be notified by this object must call this
* function before any notify_wait() invocation. It locks the mutex.
* function before any notify_wait() invocation. It locks the mutex.
*/
*/
void
notify_enter
(
N
otify
*
notify
);
void
notify_enter
(
struct
n
otify
*
notify
);
/**
/**
* Neutralize notify_leave().
* Neutralize notify_leave().
*/
*/
void
notify_leave
(
N
otify
*
notify
);
void
notify_leave
(
struct
n
otify
*
notify
);
/**
/**
* Wait for a notification. Return immediately if we have already
* Wait for a notification. Return immediately if we have already
* been notified since we last returned from notify_wait().
* been notified since we last returned from notify_wait().
*/
*/
void
notify_wait
(
N
otify
*
notify
);
void
notify_wait
(
struct
n
otify
*
notify
);
/**
/**
* Notify the thread. This function never blocks.
* Notify the thread. This function never blocks.
*/
*/
void
notify_signal
(
N
otify
*
notify
);
void
notify_signal
(
struct
n
otify
*
notify
);
/**
/**
* Notify the thread synchonously, i.e. wait until it has received the
* Notify the thread synchonously, i.e. wait until it has received the
* notification.
* notification.
*/
*/
void
notify_signal_sync
(
N
otify
*
notify
);
void
notify_signal_sync
(
struct
n
otify
*
notify
);
#endif
#endif
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