axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r377334 - /webservices/axis2/trunk/c/include/axis2_thread.h
Date Mon, 13 Feb 2006 10:27:42 GMT
Author: sahan
Date: Mon Feb 13 02:27:38 2006
New Revision: 377334

URL: http://svn.apache.org/viewcvs?rev=377334&view=rev
Log:
Added prototype for mutex locks

Modified:
    webservices/axis2/trunk/c/include/axis2_thread.h

Modified: webservices/axis2/trunk/c/include/axis2_thread.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_thread.h?rev=377334&r1=377333&r2=377334&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_thread.h (original)
+++ webservices/axis2/trunk/c/include/axis2_thread.h Mon Feb 13 02:27:38 2006
@@ -24,7 +24,8 @@
   */
 
 #include <axis2_allocator.h>
-#include <axis2.h>
+#include <axis2_defines.h>
+#include <axis2_error.h>
 
 
 
@@ -68,8 +69,8 @@
  * @param cont The pool to use
  * @return Newly created thread attribute
  */
-AXIS2_DECLARE(axis2_threadattr_t*) axis2_threadattr_create(
-						axis2_allocator_t *allocator);
+AXIS2_DECLARE(axis2_threadattr_t*) 
+axis2_threadattr_create(axis2_allocator_t *allocator);
 
 /**
  * Set if newly created threads should be created in detached state.
@@ -77,8 +78,8 @@
  * @param on Non-zero if detached threads should be created.
  * @return The status of the operation
  */
-AXIS2_DECLARE(axis2_status_t) axis2_threadattr_detach_set(
-						axis2_threadattr_t *attr, axis2_bool_t detached);
+AXIS2_DECLARE(axis2_status_t)
+axis2_threadattr_detach_set(axis2_threadattr_t *attr, axis2_bool_t detached);
 
 /**
  * Get the detach state for this threadattr.
@@ -86,8 +87,8 @@
  * @return AXIS2_TRUE if threads are to be detached, or AXIS2_FALSE
  * if threads are to be joinable.
  */
-AXIS2_DECLARE(axis2_bool_t) axis2_threadattr_is_detach(
-						axis2_threadattr_t *attr, axis2_allocator_t *allocator);
+AXIS2_DECLARE(axis2_bool_t)
+axis2_threadattr_is_detach(axis2_threadattr_t *attr, axis2_allocator_t *allocator);
 
 
 /**
@@ -98,37 +99,39 @@
  * @param cont The pool to use
  * @return The newly created thread handle.
  */
-AXIS2_DECLARE(axis2_thread_t*) axis2_thread_create(axis2_allocator_t *allocator,
-						axis2_threadattr_t *attr,
-                        axis2_thread_start_t func,
-                        void *data);
+AXIS2_DECLARE(axis2_thread_t*) 
+axis2_thread_create(axis2_allocator_t *allocator, axis2_threadattr_t *attr,
+                        axis2_thread_start_t func, void *data);
 
 /**
  * Stop the current thread
  * @param thd The thread to stop
  * @return The status of the operation
  */
-AXIS2_DECLARE(axis2_status_t) axis2_thread_exit(axis2_thread_t *thd);
+AXIS2_DECLARE(axis2_status_t) 
+axis2_thread_exit(axis2_thread_t *thd);
 
 /**
  * Block until the desired thread stops executing.
  * @param thd The thread to join
  * @return The status of the operation
  */
-AXIS2_DECLARE(axis2_status_t) axis2_thread_join(axis2_thread_t *thd);
+AXIS2_DECLARE(axis2_status_t) 
+axis2_thread_join(axis2_thread_t *thd);
 
 /**
  * force the current thread to yield the processor
  */
-AXIS2_DECLARE(void) axis2_thread_yield();
+AXIS2_DECLARE(void) 
+axis2_thread_yield();
 
 /**
  * Initialize the control variable for axis2_thread_once.
  * @param control The control variable to initialize
  * @return The status of the operation
  */
-AXIS2_DECLARE(axis2_status_t) axis2_thread_once_init(
-						axis2_thread_once_t **control, 
+AXIS2_DECLARE(axis2_status_t) 
+axis2_thread_once_init(axis2_thread_once_t **control, 
 						axis2_allocator_t *allocator);
 
 /**
@@ -141,16 +144,53 @@
  * @param func The function to call.
  * @return The status of the operation
  */
-AXIS2_DECLARE(axis2_status_t) axis2_thread_once(axis2_thread_once_t *control, 
-						void (*func)(void));
+AXIS2_DECLARE(axis2_status_t)
+axis2_thread_once(axis2_thread_once_t *control, void (*func)(void));
 
 /**
  * detach a thread
  * @param thd The thread to detach
  * @return The status of the operation
  */
-AXIS2_DECLARE(axis2_status_t) axis2_thread_detach(axis2_thread_t *thd);
+AXIS2_DECLARE(axis2_status_t) 
+axis2_thread_detach(axis2_thread_t *thd);
+
+/*************************Thread locking functions*****************************/
 
+/** Opaque thread-local mutex structure */
+typedef struct axis2_thread_mutex_t axis2_thread_mutex_t;
+
+#define AXIS2_THREAD_MUTEX_DEFAULT  0x0   /**< platform-optimal lock behavior */
+/**
+ * Create and initialize a mutex that can be used to synchronize threads.
+ * @param allocator Memory allocator to allocate memory for the mutex
+ * @warning Be cautious in using AXIS2_THREAD_MUTEX_DEFAULT.  While this is the
+ * most optimial mutex based on a given platform's performance charateristics,
+ * it will behave as either a nested or an unnested lock.
+ */
+AXIS2_DECLARE(axis2_thread_mutex_t *)
+axis2_thread_mutex_create(axis2_allocator_t *allocator, unsigned int flags);
+/**
+ * Acquire the lock for the given mutex. If the mutex is already locked,
+ * the current thread will be put to sleep until the lock becomes available.
+ * @param mutex the mutex on which to acquire the lock.
+ */
+AXIS2_DECLARE(axis2_status_t) 
+axis2_thread_mutex_lock(axis2_thread_mutex_t *mutex);
+
+/**
+ * Release the lock for the given mutex.
+ * @param mutex the mutex from which to release the lock.
+ */
+AXIS2_DECLARE(axis2_status_t) 
+axis2_thread_mutex_unlock(axis2_thread_mutex_t *mutex);
+
+/**
+ * Destroy the mutex and free the memory associated with the lock.
+ * @param mutex the mutex to destroy.
+ */
+AXIS2_DECLARE(axis2_status_t)
+axis2_thread_mutex_destroy(axis2_thread_mutex_t *mutex);
 
 /** @} */
 #ifdef __cplusplus



Mime
View raw message