celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abroekh...@apache.org
Subject svn commit: r1600144 - in /incubator/celix/trunk: framework/private/include/framework_private.h framework/private/src/framework.c framework/private/src/utils.c utils/private/src/celix_threads.c utils/public/include/celix_threads.h
Date Wed, 04 Jun 2014 12:27:53 GMT
Author: abroekhuis
Date: Wed Jun  4 12:27:53 2014
New Revision: 1600144

URL: http://svn.apache.org/r1600144
Log:
CELIX-119: Updated thread and mutex wrapper

Modified:
    incubator/celix/trunk/framework/private/include/framework_private.h
    incubator/celix/trunk/framework/private/src/framework.c
    incubator/celix/trunk/framework/private/src/utils.c
    incubator/celix/trunk/utils/private/src/celix_threads.c
    incubator/celix/trunk/utils/public/include/celix_threads.h

Modified: incubator/celix/trunk/framework/private/include/framework_private.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/framework_private.h?rev=1600144&r1=1600143&r2=1600144&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/framework_private.h (original)
+++ incubator/celix/trunk/framework/private/include/framework_private.h Wed Jun  4 12:27:53
2014
@@ -28,8 +28,6 @@
 #ifndef FRAMEWORK_PRIVATE_H_
 #define FRAMEWORK_PRIVATE_H_
 
-#include <apr_thread_cond.h>
-
 #include "framework.h"
 
 #include "manifest.h"
@@ -61,14 +59,14 @@ struct framework {
     struct serviceRegistry * registry;
     bundle_cache_pt cache;
 
-    apr_thread_cond_t *shutdownGate;
-    apr_thread_cond_t *condition;
+    celix_thread_cond_t *shutdownGate;
+    celix_thread_cond_t *condition;
 
-    apr_thread_mutex_t *installRequestLock;
-    apr_thread_mutex_t *mutex;
-    apr_thread_mutex_t *bundleLock;
+    celix_thread_mutex_t *installRequestLock;
+    celix_thread_mutex_t *mutex;
+    celix_thread_mutex_t *bundleLock;
 
-    apr_os_thread_t globalLockThread;
+    celix_thread_t globalLockThread;
     array_list_pt globalLockWaitersList;
     int globalLockCount;
 
@@ -80,8 +78,8 @@ struct framework {
     properties_pt configurationMap;
 
     array_list_pt requests;
-    apr_thread_cond_t *dispatcher;
-    apr_thread_mutex_t *dispatcherLock;
+    celix_thread_cond_t dispatcher;
+    celix_thread_mutex_t dispatcherLock;
     celix_thread_t dispatcherThread;
 
     framework_logger_pt logger;

Modified: incubator/celix/trunk/framework/private/src/framework.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/framework.c?rev=1600144&r1=1600143&r2=1600144&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/framework.c (original)
+++ incubator/celix/trunk/framework/private/src/framework.c Wed Jun  4 12:27:53 2014
@@ -180,12 +180,12 @@ celix_status_t framework_create(framewor
     if (*framework != NULL) {
         apr_status_t apr_status = APR_SUCCESS;
         apr_status = CELIX_DO_IF(apr_status, apr_pool_create(&(*framework)->mp, memoryPool));
-        apr_status = CELIX_DO_IF(apr_status, apr_thread_cond_create(&(*framework)->condition,
(*framework)->mp));
-        apr_status = CELIX_DO_IF(apr_status, apr_thread_mutex_create(&(*framework)->mutex,
APR_THREAD_MUTEX_UNNESTED, (*framework)->mp));
-        apr_status = CELIX_DO_IF(apr_status, apr_thread_mutex_create(&(*framework)->bundleLock,
APR_THREAD_MUTEX_UNNESTED, (*framework)->mp));
-        apr_status = CELIX_DO_IF(apr_status, apr_thread_mutex_create(&(*framework)->installRequestLock,
APR_THREAD_MUTEX_UNNESTED, (*framework)->mp));
-        apr_status = CELIX_DO_IF(apr_status, apr_thread_mutex_create(&(*framework)->dispatcherLock,
APR_THREAD_MUTEX_UNNESTED, (*framework)->mp));
-        apr_status = CELIX_DO_IF(apr_status, apr_thread_cond_create(&(*framework)->dispatcher,
(*framework)->mp));
+        apr_status = CELIX_DO_IF(apr_status, celixThreadCondition_init(&(*framework)->condition,
NULL));
+        apr_status = CELIX_DO_IF(apr_status, celixThreadMutex_create(&(*framework)->mutex,
NULL));
+        apr_status = CELIX_DO_IF(apr_status, celixThreadMutex_create(&(*framework)->bundleLock,
NULL));
+        apr_status = CELIX_DO_IF(apr_status, celixThreadMutex_create(&(*framework)->installRequestLock,
NULL));
+        apr_status = CELIX_DO_IF(apr_status, celixThreadMutex_create(&(*framework)->dispatcherLock,
NULL));
+        apr_status = CELIX_DO_IF(apr_status, celixThreadCondition_init(&(*framework)->dispatcher,
NULL));
         if (apr_status == APR_SUCCESS) {
             (*framework)->bundle = NULL;
             (*framework)->installedBundleMap = NULL;
@@ -388,7 +388,7 @@ celix_status_t fw_init(framework_pt fram
 
     status = CELIX_DO_IF(status, serviceRegistry_create(framework->mp, framework, fw_serviceChanged,
&framework->registry));
     status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, framework->bundle,
OSGI_FRAMEWORK_BUNDLE_STARTING));
-    status = CELIX_DO_IF(status, apr_thread_cond_create(&framework->shutdownGate,
framework->mp));
+    status = CELIX_DO_IF(status, celixThreadCondition_init(&framework->shutdownGate,
NULL));
     if (status == CELIX_SUCCESS) {
         handle_t handle = NULL;
         handle = fw_getSystemLibrary();
@@ -1749,25 +1749,25 @@ bundle_pt framework_getBundleById(framew
 }
 
 celix_status_t framework_acquireInstallLock(framework_pt framework, char * location) {
-    apr_thread_mutex_lock(framework->installRequestLock);
+    celixThreadMutex_lock(&framework->installRequestLock);
 
 	while (hashMap_get(framework->installRequestMap, location) != NULL) {
-		apr_thread_cond_wait(framework->condition, framework->installRequestLock);
+	    celixThreadCondition_wait(&framework->condition, &framework->installRequestLock);
 	}
 	hashMap_put(framework->installRequestMap, location, location);
 
-	apr_thread_mutex_unlock(framework->installRequestLock);
+	celixThreadMutex_unlock(&framework->installRequestLock);
 
 	return CELIX_SUCCESS;
 }
 
 celix_status_t framework_releaseInstallLock(framework_pt framework, char * location) {
-    apr_thread_mutex_lock(framework->installRequestLock);
+    celixThreadMutex_lock(&framework->installRequestLock);
 
 	hashMap_remove(framework->installRequestMap, location);
-	apr_thread_cond_broadcast(framework->condition);
+	celixThreadCondition_broadcast(&framework->condition);
 
-	apr_thread_mutex_unlock(framework->installRequestLock);
+	celixThreadMutex_unlock(&framework->installRequestLock);
 
 	return CELIX_SUCCESS;
 }
@@ -1775,20 +1775,20 @@ celix_status_t framework_releaseInstallL
 celix_status_t framework_setBundleStateAndNotify(framework_pt framework, bundle_pt bundle,
int state) {
 	int ret = CELIX_SUCCESS;
 
-	int err = apr_thread_mutex_lock(framework->bundleLock);
+	int err = celixThreadMutex_lock(&framework->bundleLock);
 	if (err != 0) {
 		fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Failed to lock");
 		return CELIX_BUNDLE_EXCEPTION;
 	}
 
 	bundle_setState(bundle, state);
-	err = apr_thread_cond_broadcast(framework->condition);
+	err = celixThreadCondition_broadcast(&framework->condition);
 	if (err != 0) {
 		fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Failed to broadcast");
 		ret = CELIX_BUNDLE_EXCEPTION;
 	}
 
-	err = apr_thread_mutex_unlock(framework->bundleLock);
+	err = celixThreadMutex_unlock(&framework->bundleLock);
 	if (err != 0) {
 		fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Failed to unlock");
 		return CELIX_BUNDLE_EXCEPTION;
@@ -1802,7 +1802,7 @@ celix_status_t framework_acquireBundleLo
 	bool locked;
 	apr_os_thread_t lockingThread = 0;
 
-	int err = apr_thread_mutex_lock(framework->bundleLock);
+	int err = celixThreadMutex_lock(&framework->bundleLock);
 	if (err != APR_SUCCESS) {
 		fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Failed to lock");
 		status = CELIX_BUNDLE_EXCEPTION;
@@ -1811,6 +1811,7 @@ celix_status_t framework_acquireBundleLo
 		bool isSelf = false;
 
 		bundle_isLockable(bundle, &lockable);
+		// #TODO
 		thread_equalsSelf(framework->globalLockThread, &isSelf);
 
 		while (!lockable
@@ -1827,11 +1828,11 @@ celix_status_t framework_acquireBundleLo
 					&& (lockingThread != 0)
 					&& arrayList_contains(framework->globalLockWaitersList, &lockingThread))
{
 				framework->interrupted = true;
-	//			pthread_cond_signal_thread_np(&framework->condition, bundle_getLockingThread(bundle));
-				apr_thread_cond_signal(framework->condition);
+				celixThreadCondition_signal_thread_np(&framework->condition, bundle_getLockingThread(bundle));
+//				celixThreadCondition_signal(framework->condition);
 			}
 
-			apr_thread_cond_wait(framework->condition, framework->bundleLock);
+            celixThreadCondition_wait(framework->condition, framework->bundleLock);
 
 			status = bundle_isLockable(bundle, &lockable);
 			if (status != CELIX_SUCCESS) {
@@ -1852,7 +1853,7 @@ celix_status_t framework_acquireBundleLo
 				}
 			}
 		}
-		apr_thread_mutex_unlock(framework->bundleLock);
+		celixThreadMutex_unlock(framework->bundleLock);
 	}
 
 	framework_logIfError(framework->logger, status, NULL, "Failed to get bundle lock");
@@ -1864,19 +1865,19 @@ bool framework_releaseBundleLock(framewo
     bool unlocked;
     apr_os_thread_t lockingThread = 0;
 
-    apr_thread_mutex_lock(framework->bundleLock);
+    celixThreadMutex_lock(framework->bundleLock);
 
     bundle_unlock(bundle, &unlocked);
 	if (!unlocked) {
-	    apr_thread_mutex_unlock(framework->bundleLock);
+	    celixThreadMutex_unlock(framework->bundleLock);
 		return false;
 	}
 	bundle_getLockingThread(bundle, &lockingThread);
 	if (lockingThread == 0) {
-	    apr_thread_cond_broadcast(framework->condition);
+	    celixThreadCondition_broadcast(framework->condition);
 	}
 
-	apr_thread_mutex_unlock(framework->bundleLock);
+	celixThreadMutex_unlock(framework->bundleLock);
 
 	return true;
 }
@@ -1885,18 +1886,18 @@ bool framework_acquireGlobalLock(framewo
     bool interrupted = false;
 	bool isSelf = false;
 
-	apr_thread_mutex_lock(framework->bundleLock);
+	celixThreadMutex_lock(framework->bundleLock);
 
 	thread_equalsSelf(framework->globalLockThread, &isSelf);
 
 	while (!interrupted
 			&& (framework->globalLockThread != 0)
 			&& (!isSelf)) {
-		apr_os_thread_t currentThread = apr_os_thread_current();
+		celix_thread_t currentThread = celixThread_self();
 		arrayList_add(framework->globalLockWaitersList, &currentThread);
-		apr_thread_cond_broadcast(framework->condition);
+		celixThreadCondition_broadcast(framework->condition);
 
-		apr_thread_cond_wait(framework->condition, framework->bundleLock);
+		celixThreadCondition_wait(framework->condition, framework->bundleLock);
 		if (framework->interrupted) {
 			interrupted = true;
 			framework->interrupted = false;
@@ -1907,17 +1908,17 @@ bool framework_acquireGlobalLock(framewo
 
 	if (!interrupted) {
 		framework->globalLockCount++;
-		framework->globalLockThread = apr_os_thread_current();
+		framework->globalLockThread = celixThread_self();
 	}
 
-	apr_thread_mutex_unlock(framework->bundleLock);
+	celixThreadMutex_unlock(framework->bundleLock);
 
 	return !interrupted;
 }
 
 celix_status_t framework_releaseGlobalLock(framework_pt framework) {
 	int status = CELIX_SUCCESS;
-	if (apr_thread_mutex_lock(framework->bundleLock) != 0) {
+	if (celixThreadMutex_lock(framework->bundleLock) != 0) {
 		fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error locking framework bundle
lock");
 		return CELIX_FRAMEWORK_EXCEPTION;
 	}
@@ -1926,7 +1927,7 @@ celix_status_t framework_releaseGlobalLo
 		framework->globalLockCount--;
 		if (framework->globalLockCount == 0) {
 			framework->globalLockThread = 0;
-			if (apr_thread_cond_broadcast(framework->condition) != 0) {
+			if (celixThreadCondition_broadcast(framework->condition) != 0) {
 				fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Failed to broadcast global lock
release.");
 				status = CELIX_FRAMEWORK_EXCEPTION;
 				// still need to unlock before returning
@@ -1936,7 +1937,7 @@ celix_status_t framework_releaseGlobalLo
 		printf("The current thread does not own the global lock");
 	}
 
-	if (apr_thread_mutex_unlock(framework->bundleLock) != 0) {
+	if (celixThreadMutex_unlock(framework->bundleLock) != 0) {
 		fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error unlocking framework bundle
lock");
 		return CELIX_FRAMEWORK_EXCEPTION;
 	}
@@ -1947,18 +1948,18 @@ celix_status_t framework_releaseGlobalLo
 }
 
 celix_status_t framework_waitForStop(framework_pt framework) {
-	if (apr_thread_mutex_lock(framework->mutex) != 0) {
+	if (celixThreadMutex_lock(framework->mutex) != 0) {
 		fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, "Error locking the framework, shutdown
gate not set.");
 		return CELIX_FRAMEWORK_EXCEPTION;
 	}
 	while (!framework->shutdown) {
-		apr_status_t apr_status = apr_thread_cond_wait(framework->shutdownGate, framework->mutex);
+		apr_status_t apr_status = celixThreadCondition_wait(framework->shutdownGate, framework->mutex);
 		if (apr_status != 0) {
 			fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, "Error waiting for shutdown gate.");
 			return CELIX_FRAMEWORK_EXCEPTION;
 		}
 	}
-	if (apr_thread_mutex_unlock(framework->mutex) != 0) {
+	if (celixThreadMutex_unlock(framework->mutex) != 0) {
 		fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, "Error unlocking the framework.");
 		return CELIX_FRAMEWORK_EXCEPTION;
 	}
@@ -1990,31 +1991,31 @@ static void *APR_THREAD_FUNC framework_s
 	}
 	hashMapIterator_destroy(iterator);
 
-	err = apr_thread_mutex_lock(fw->mutex);
+	err = celixThreadMutex_lock(fw->mutex);
 	if (err != 0) {
 		fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error locking the framework, cannot exit
clean.");
-		apr_thread_exit(thd, APR_ENOLOCK);
+		celixThread_exit(NULL);
 		return NULL;
 	}
 	fw->shutdown = true;
-	err = apr_thread_cond_broadcast(fw->shutdownGate);
+	err = celixThreadCondition_broadcast(fw->shutdownGate);
 	if (err != 0) {
 		fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error waking the shutdown gate, cannot
exit clean.");
-		err = apr_thread_mutex_unlock(fw->mutex);
+		err = celixThreadMutex_unlock(fw->mutex);
 		if (err != 0) {
 			fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error unlocking the framework, cannot
exit clean.");
 		}
 
-		apr_thread_exit(thd, APR_ENOLOCK);
+		celixThread_exit(NULL);
 		return NULL;
 	}
-	err = apr_thread_mutex_unlock(fw->mutex);
+	err = celixThreadMutex_unlock(fw->mutex);
 	if (err != 0) {
 		fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error unlocking the framework, cannot
exit clean.");
 	}
 
 	fw_log(fw->logger, OSGI_FRAMEWORK_LOG_INFO, "FRAMEWORK: Shutdown done\n");
-	apr_thread_exit(thd, APR_SUCCESS);
+	celixThread_exit(thd, APR_SUCCESS);
 
 	return NULL;
 }
@@ -2051,13 +2052,13 @@ celix_status_t fw_fireBundleEvent(framew
 			request->error = NULL;
 
 			arrayList_add(framework->requests, request);
-			if (apr_thread_mutex_lock(framework->dispatcherLock) != APR_SUCCESS) {
+			if (celixThreadMutex_lock(&framework->dispatcherLock) != CELIX_SUCCESS) {
 				status = CELIX_FRAMEWORK_EXCEPTION;
 			} else {
-				if (apr_thread_cond_broadcast(framework->dispatcher)) {
+				if (celixThreadCondition_broadcast(&framework->dispatcher)) {
 					status = CELIX_FRAMEWORK_EXCEPTION;
 				} else {
-					if (apr_thread_mutex_unlock(framework->dispatcherLock)) {
+					if (celixThreadMutex_unlock(&framework->dispatcherLock)) {
 						status = CELIX_FRAMEWORK_EXCEPTION;
 					}
 				}
@@ -2091,13 +2092,13 @@ celix_status_t fw_fireFrameworkEvent(fra
 		}
 
 		arrayList_add(framework->requests, request);
-		if (apr_thread_mutex_lock(framework->dispatcherLock) != APR_SUCCESS) {
+		if (celixThreadMutex_lock(&framework->dispatcherLock) != APR_SUCCESS) {
 			status = CELIX_FRAMEWORK_EXCEPTION;
 		} else {
-			if (apr_thread_cond_broadcast(framework->dispatcher)) {
+			if (celixThreadCondition_broadcast(&framework->dispatcher)) {
 				status = CELIX_FRAMEWORK_EXCEPTION;
 			} else {
-				if (apr_thread_mutex_unlock(framework->dispatcherLock)) {
+				if (celixThreadMutex_unlock(&framework->dispatcherLock)) {
 					status = CELIX_FRAMEWORK_EXCEPTION;
 				}
 			}
@@ -2117,7 +2118,7 @@ static void *fw_eventDispatcher(void *fw
 		int size;
 		apr_status_t status;
 
-		if (apr_thread_mutex_lock(framework->dispatcherLock) != 0) {
+		if (celixThreadMutex_lock(&framework->dispatcherLock) != 0) {
 			fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error locking the dispatcher");
 			celixThread_exit(NULL);
 			return NULL;
@@ -2125,7 +2126,7 @@ static void *fw_eventDispatcher(void *fw
 
 		size = arrayList_size(framework->requests);
 		while (size == 0 && !framework->shutdown) {
-			apr_status_t apr_status = apr_thread_cond_wait(framework->dispatcher, framework->dispatcherLock);
+			apr_status_t apr_status = celixThreadCondition_wait(&framework->dispatcher, &framework->dispatcherLock);
 			// Ignore status and just keep waiting
 			size = arrayList_size(framework->requests);
 		}
@@ -2137,7 +2138,7 @@ static void *fw_eventDispatcher(void *fw
 		
 		request = (request_pt) arrayList_remove(framework->requests, 0);
 
-		if ((status = apr_thread_mutex_unlock(framework->dispatcherLock)) != 0) {
+		if ((status = celixThreadMutex_unlock(&framework->dispatcherLock)) != 0) {
 			fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error unlocking the dispatcher.");
 			celixThread_exit(NULL);
 			return NULL;
@@ -2204,15 +2205,15 @@ celix_status_t bundleActivator_start(voi
 celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
     celix_status_t status = CELIX_SUCCESS;
 
-	apr_thread_t *shutdownThread;
+	celix_thread_t shutdownThread;
 	framework_pt framework;
 
 	if (bundleContext_getFramework(context, &framework) == CELIX_SUCCESS) {
 
 	    fw_log(framework->logger, OSGI_FRAMEWORK_LOG_INFO, "FRAMEWORK: Start shutdownthread");
-	    if (apr_thread_create(&shutdownThread, NULL, framework_shutdown, framework, framework->mp)
== APR_SUCCESS) {
-//            apr_thread_join(&status, shutdownThread);
-            apr_thread_detach(shutdownThread);
+	    if (celixThread_create(&shutdownThread, NULL, framework_shutdown, framework) ==
CELIX_SUCCESS) {
+//            celixThread_join(&status, shutdownThread);
+	        celixThread_detach(shutdownThread);
 	    } else {
             fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Could not create shutdown
thread, normal exit not possible.");
 	        status = CELIX_FRAMEWORK_EXCEPTION;

Modified: incubator/celix/trunk/framework/private/src/utils.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/utils.c?rev=1600144&r1=1600143&r2=1600144&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/utils.c (original)
+++ incubator/celix/trunk/framework/private/src/utils.c Wed Jun  4 12:27:53 2014
@@ -83,7 +83,7 @@ char * utils_stringTrim(char * string) {
 	return copy;
 }
 
-celix_status_t thread_equalsSelf(apr_os_thread_t thread, bool *equals) {
+celix_status_t thread_equalsSelf(celix_thread_t thread, bool *equals) {
 	celix_status_t status = CELIX_SUCCESS;
 
 	apr_os_thread_t self = apr_os_thread_current();

Modified: incubator/celix/trunk/utils/private/src/celix_threads.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/utils/private/src/celix_threads.c?rev=1600144&r1=1600143&r2=1600144&view=diff
==============================================================================
--- incubator/celix/trunk/utils/private/src/celix_threads.c (original)
+++ incubator/celix/trunk/utils/private/src/celix_threads.c Wed Jun  4 12:27:53 2014
@@ -27,23 +27,55 @@
 #include "celix_threads.h"
 
 celix_status_t celixThread_create(celix_thread_t *new_thread, celix_thread_attr_t *attr,
celix_thread_start_t func, void *data) {
+    return pthread_create(new_thread, attr, func, data);
+}
+
+celix_status_t celixThread_exit(void *exitStatus) {
     celix_status_t status = CELIX_SUCCESS;
+    pthread_exit(exitStatus);
+    return status;
+}
 
-    pthread_create(new_thread, attr, func, data);
+celix_status_t celixThread_detach(celix_thread_t thread) {
+    return pthread_detach(thread);
+}
 
-    return status;
+celix_status_t celixThread_detach(celix_thread_t thread, void **status) {
+    return pthread_join(thread, status);
 }
 
-celix_status_t celixThread_exit(void *exitStatus) {
-    celix_status_t status = CELIX_SUCCESS;
+celix_thread_t celixThread_self() {
+    return pthread_self();
+}
 
-    pthread_exit(exitStatus);
+celix_status_t celixThreadMutex_create(celix_thread_mutex_t *mutex, celix_thread_mutexattr_t
*attr) {
+    return pthread_mutex_init(mutex, attr);
+}
 
-    return status;
+celix_status_t celixThreadMutex_lock(celix_thread_mutex_t *mutex) {
+    return pthread_mutex_lock(mutex);
+}
+
+celix_status_t celixThreadMutex_unlock(celix_thread_mutex_t *mutex) {
+    return pthread_mutex_unlock(mutex);
+}
+
+celix_status_t celixThreadCondition_init(celix_thread_cond_t *condition, celix_thread_condattr_t
*attr) {
+    return pthread_cond_init(condition, attr);
 }
 
+celix_status_t celixThreadCondition_wait(celix_thread_cond_t *cond, celix_thread_mutex_t
*mutex) {
+    return pthread_cond_wait(cond, mutex);
+}
+
+celix_status_t celixThreadCondition_broadcast(celix_thread_cond_t *cond) {
+    return pthread_cond_broadcast(cond);
+}
+
+celix_status_t celixThreadCondition_signal(celix_thread_cond_t *cond) {
+    return pthread_cond_signal(cond);
+}
 
-celix_status_t celixThreadMutext_create(celix_thread_mutex_t *mutex, celix_thread_mutexattr_t
*attr) {
-    pthread_mutex_init(mutex, attr);
-    return CELIX_SUCCESS;
+celix_status_t celixThreadCondition_signalThreadNp(celix_thread_cond_t *cond, celix_thread_t
*thread) {
+    return pthread_cond_signal_thread_np(cond, thread);
 }

Modified: incubator/celix/trunk/utils/public/include/celix_threads.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/utils/public/include/celix_threads.h?rev=1600144&r1=1600143&r2=1600144&view=diff
==============================================================================
--- incubator/celix/trunk/utils/public/include/celix_threads.h (original)
+++ incubator/celix/trunk/utils/public/include/celix_threads.h Wed Jun  4 12:27:53 2014
@@ -38,12 +38,24 @@ typedef void *(*celix_thread_start_t)(vo
 
 celix_status_t celixThread_create(celix_thread_t *new_thread, celix_thread_attr_t *attr,
celix_thread_start_t func, void *data);
 celix_status_t celixThread_exit(void *exitStatus);
+celix_status_t celixThread_detach(celix_thread_t thread);
+celix_status_t celixThread_detach(celix_thread_t thread, void **status);
+celix_thread_t celixThread_self();
 
 typedef pthread_mutex_t celix_thread_mutex_t;
 typedef pthread_mutexattr_t celix_thread_mutexattr_t;
 
-celix_status_t celixThreadMutext_create(celix_thread_mutex_t *mutex, celix_thread_mutexattr_t
*attr);
-
-
+celix_status_t celixThreadMutex_create(celix_thread_mutex_t *mutex, celix_thread_mutexattr_t
*attr);
+celix_status_t celixThreadMutex_lock(celix_thread_mutex_t *mutex);
+celix_status_t celixThreadMutex_unlock(celix_thread_mutex_t *mutex);
+
+typedef pthread_cond_t celix_thread_cond_t;
+typedef pthread_condattr_t celix_thread_condattr_t;
+
+celix_status_t celixThreadCondition_init(celix_thread_cond_t *condition, celix_thread_condattr_t
*attr);
+celix_status_t celixThreadCondition_wait(celix_thread_cond_t *cond, celix_thread_mutex_t
*mutex);
+celix_status_t celixThreadCondition_broadcast(celix_thread_cond_t *cond);
+celix_status_t celixThreadCondition_signal(celix_thread_cond_t *cond);
+celix_status_t celixThreadCondition_signalThreadNp(celix_thread_cond_t *cond, celix_thread_t
*thread);
 
 #endif /* CELIX_THREADS_H_ */



Mime
View raw message