summaryrefslogtreecommitdiff
path: root/src/common/mutex.h
diff options
context:
space:
mode:
authorTrojal <trojal@gmail.com>2013-01-10 20:09:39 -0800
committerTrojal <trojal@gmail.com>2013-01-10 20:32:02 -0800
commit83e7a4954437c13aec639b0b512252cc20a8f36c (patch)
treeb7f6d11b2058248d026f2d9944e8f4b6ac288d50 /src/common/mutex.h
parent51bfeb38eb139e97e0e1c096c85c15fba234f35b (diff)
parent38e583df21eccd9e4f31d38acaae32579c6f0d27 (diff)
downloadhercules-83e7a4954437c13aec639b0b512252cc20a8f36c.tar.gz
hercules-83e7a4954437c13aec639b0b512252cc20a8f36c.tar.bz2
hercules-83e7a4954437c13aec639b0b512252cc20a8f36c.tar.xz
hercules-83e7a4954437c13aec639b0b512252cc20a8f36c.zip
Merge rathena repository to form Hercules initial commit.
Diffstat (limited to 'src/common/mutex.h')
-rw-r--r--src/common/mutex.h92
1 files changed, 92 insertions, 0 deletions
diff --git a/src/common/mutex.h b/src/common/mutex.h
new file mode 100644
index 000000000..1999627cd
--- /dev/null
+++ b/src/common/mutex.h
@@ -0,0 +1,92 @@
+// Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL
+// For more information, see LICENCE in the main folder
+
+#ifndef _rA_MUTEX_H_
+#define _rA_MUTEX_H_
+
+
+typedef struct ramutex *ramutex; // Mutex
+typedef struct racond *racond; // Condition Var
+
+/**
+ * Creates a Mutex
+ *
+ * @return not NULL
+ */
+ramutex ramutex_create();
+
+/**
+ * Destroys a Mutex
+ *
+ * @param m - the mutex to destroy
+ */
+void ramutex_destroy( ramutex m );
+
+/**
+ * Gets a lock
+ *
+ * @param m - the mutex to lock
+ */
+void ramutex_lock( ramutex m);
+
+/**
+ * Trys to get the Lock
+ *
+ * @param m - the mutex try to lock
+ *
+ * @return boolean (true = got the lock)
+ */
+bool ramutex_trylock( ramutex m );
+
+/**
+ * Unlocks a mutex
+ *
+ * @param m - the mutex to unlock
+ */
+void ramutex_unlock( ramutex m);
+
+
+/**
+ * Creates a Condition variable
+ *
+ * @return not NULL
+ */
+racond racond_create();
+
+/**
+ * Destroy a Condition variable
+ *
+ * @param c - the condition varaible to destroy
+ */
+void racond_destroy( racond c );
+
+/**
+ * Waits Until state is signalled
+ *
+ * @param c - the condition var to wait for signalled state
+ * @param m - the mutex used for syncronization
+ * @param timeout_ticks - timeout in ticks ( -1 = INFINITE )
+ */
+void racond_wait( racond c, ramutex m, sysint timeout_ticks);
+
+/**
+ * Sets the given condition var to signalled state
+ *
+ * @param c - condition var to set in signalled state.
+ *
+ * @note:
+ * Only one waiter gets notified.
+ */
+void racond_signal( racond c );
+
+/**
+ * Sets notifys all waiting threads thats signalled.
+ * @param c - condition var to set in signalled state
+ *
+ * @note:
+ * All Waiters getting notified.
+ */
+void racond_broadcast( racond c );
+
+
+#endif