Commit 770b1405 authored by Max Kellermann's avatar Max Kellermann

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
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include "notify.h" #include "notify.h"
int notify_init(Notify *notify) int notify_init(struct notify *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(Notify *notify) void notify_enter(struct notify *notify)
{ {
pthread_mutex_lock(&notify->mutex); pthread_mutex_lock(&notify->mutex);
} }
void notify_leave(Notify *notify) void notify_leave(struct notify *notify)
{ {
pthread_mutex_unlock(&notify->mutex); pthread_mutex_unlock(&notify->mutex);
} }
void notify_wait(Notify *notify) void notify_wait(struct notify *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(Notify *notify) void notify_signal(struct notify *notify)
{ {
notify->pending = 1; notify->pending = 1;
pthread_cond_signal(&notify->cond); pthread_cond_signal(&notify->cond);
} }
void notify_signal_sync(Notify *notify) void notify_signal_sync(struct notify *notify)
{ {
pthread_mutex_lock(&notify->mutex); pthread_mutex_lock(&notify->mutex);
notify_signal(notify); notify_signal(notify);
......
...@@ -21,40 +21,40 @@ ...@@ -21,40 +21,40 @@
#include "os_compat.h" #include "os_compat.h"
typedef struct _Notify { typedef struct notify {
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(Notify *notify); int notify_init(struct notify *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(Notify *notify); void notify_enter(struct notify *notify);
/** /**
* Neutralize notify_leave(). * Neutralize notify_leave().
*/ */
void notify_leave(Notify *notify); void notify_leave(struct notify *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(Notify *notify); void notify_wait(struct notify *notify);
/** /**
* Notify the thread. This function never blocks. * Notify the thread. This function never blocks.
*/ */
void notify_signal(Notify *notify); void notify_signal(struct notify *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(Notify *notify); void notify_signal_sync(struct notify *notify);
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment