incubator-celix-commits mailing list archives

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

URL: http://svn.apache.org/r1600111
Log:
CELIX-119: Added source file for pthread abstraction.

Added:
    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
    incubator/celix/trunk/framework/private/src/framework.c
    incubator/celix/trunk/utils/CMakeLists.txt

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=1600111&r1=1600110&r2=1600111&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/framework_private.h (original)
+++ incubator/celix/trunk/framework/private/include/framework_private.h Wed Jun  4 11:27:47
2014
@@ -47,6 +47,8 @@
 #include "bundle_cache.h"
 #include "celix_log.h"
 
+#include "celix_threads.h"
+
 struct framework {
     struct bundle * bundle;
     hash_map_pt installedBundleMap;
@@ -80,7 +82,7 @@ struct framework {
     array_list_pt requests;
     apr_thread_cond_t *dispatcher;
     apr_thread_mutex_t *dispatcherLock;
-    apr_thread_t *dispatcherThread;
+    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=1600111&r1=1600110&r2=1600111&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/framework.c (original)
+++ incubator/celix/trunk/framework/private/src/framework.c Wed Jun  4 11:27:47 2014
@@ -64,6 +64,8 @@
 #include "service_registration.h"
 #include "celix_log.h"
 
+#include "celix_threads.h"
+
 typedef celix_status_t (*create_function_pt)(bundle_context_pt context, void **userData);
 typedef celix_status_t (*start_function_pt)(void * handle, bundle_context_pt context);
 typedef celix_status_t (*stop_function_pt)(void * handle, bundle_context_pt context);
@@ -99,7 +101,7 @@ celix_status_t fw_populateDependentGraph
 
 celix_status_t fw_fireBundleEvent(framework_pt framework, bundle_event_type_e, bundle_pt
bundle);
 celix_status_t fw_fireFrameworkEvent(framework_pt framework, framework_event_type_e eventType,
bundle_pt bundle, celix_status_t errorCode);
-static void *APR_THREAD_FUNC fw_eventDispatcher(apr_thread_t *thd, void *fw);
+static void *fw_eventDispatcher(void *fw);
 
 celix_status_t fw_invokeBundleListener(framework_pt framework, bundle_listener_pt listener,
bundle_event_pt event, bundle_pt bundle);
 celix_status_t fw_invokeFrameworkListener(framework_pt framework, framework_listener_pt listener,
framework_event_pt event, bundle_pt bundle);
@@ -317,7 +319,7 @@ celix_status_t fw_init(framework_pt fram
 	status = CELIX_DO_IF(status, arrayList_create(&framework->bundleListeners));
 	status = CELIX_DO_IF(status, arrayList_create(&framework->frameworkListeners));
 	status = CELIX_DO_IF(status, arrayList_create(&framework->requests));
-	status = CELIX_DO_IF(status, apr_thread_create(&framework->dispatcherThread, NULL,
fw_eventDispatcher, framework, framework->mp));
+	status = CELIX_DO_IF(status, celixThread_create(&framework->dispatcherThread, NULL,
fw_eventDispatcher, framework));
 	status = CELIX_DO_IF(status, bundle_getState(framework->bundle, &state));
 	if (status == CELIX_SUCCESS) {
 	    if ((state == OSGI_FRAMEWORK_BUNDLE_INSTALLED) || (state == OSGI_FRAMEWORK_BUNDLE_RESOLVED))
{
@@ -2107,7 +2109,7 @@ celix_status_t fw_fireFrameworkEvent(fra
 	return status;
 }
 
-static void *APR_THREAD_FUNC fw_eventDispatcher(apr_thread_t *thd, void *fw) {
+static void *fw_eventDispatcher(void *fw) {
 	framework_pt framework = (framework_pt) fw;
 	request_pt request = NULL;
 
@@ -2117,6 +2119,7 @@ static void *APR_THREAD_FUNC fw_eventDis
 
 		if (apr_thread_mutex_lock(framework->dispatcherLock) != 0) {
 			fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error locking the dispatcher");
+			celixThread_exit(NULL);
 			return NULL;
 		}
 
@@ -2128,7 +2131,7 @@ static void *APR_THREAD_FUNC fw_eventDis
 		}
 
 		if (size == 0 && framework->shutdown) {
-			apr_thread_exit(thd, APR_SUCCESS);
+			celixThread_exit(NULL);
 			return NULL;
 		}
 		
@@ -2136,7 +2139,7 @@ static void *APR_THREAD_FUNC fw_eventDis
 
 		if ((status = apr_thread_mutex_unlock(framework->dispatcherLock)) != 0) {
 			fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error unlocking the dispatcher.");
-			apr_thread_exit(thd, status);
+			celixThread_exit(NULL);
 			return NULL;
 		}
 
@@ -2165,7 +2168,7 @@ static void *APR_THREAD_FUNC fw_eventDis
 		}
 	}
 
-	apr_thread_exit(thd, APR_SUCCESS);
+	celixThread_exit(NULL);
 
 	return NULL;
 

Modified: incubator/celix/trunk/utils/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/utils/CMakeLists.txt?rev=1600111&r1=1600110&r2=1600111&view=diff
==============================================================================
--- incubator/celix/trunk/utils/CMakeLists.txt (original)
+++ incubator/celix/trunk/utils/CMakeLists.txt Wed Jun  4 11:27:47 2014
@@ -41,6 +41,8 @@ if (UTILS) 
 		private/src/netstring.c
 		public/include/netstring.h
 		public/include/exports.h
+		
+		private/src/celix_threads.c
 	)
     
     IF(UNIX)

Added: 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=1600111&view=auto
==============================================================================
--- incubator/celix/trunk/utils/private/src/celix_threads.c (added)
+++ incubator/celix/trunk/utils/private/src/celix_threads.c Wed Jun  4 11:27:47 2014
@@ -0,0 +1,49 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * celix_threads.c
+ *
+ *  \date       4 Jun 2014
+ *  \author     <a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project
Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+#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) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    pthread_create(new_thread, attr, func, data);
+
+    return status;
+}
+
+celix_status_t celixThread_exit(void *exitStatus) {
+    celix_status_t status = CELIX_SUCCESS;
+
+    pthread_exit(exitStatus);
+
+    return status;
+}
+
+
+celix_status_t celixThreadMutext_create(celix_thread_mutex_t *mutex, celix_thread_mutexattr_t
*attr) {
+    pthread_mutex_init(mutex, attr);
+    return CELIX_SUCCESS;
+}

Added: 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=1600111&view=auto
==============================================================================
--- incubator/celix/trunk/utils/public/include/celix_threads.h (added)
+++ incubator/celix/trunk/utils/public/include/celix_threads.h Wed Jun  4 11:27:47 2014
@@ -0,0 +1,49 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * celix_threads.h
+ *
+ *  \date       4 Jun 2014
+ *  \author     <a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project
Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+#ifndef CELIX_THREADS_H_
+#define CELIX_THREADS_H_
+
+#include <pthread.h>
+
+#include "celix_errno.h"
+
+typedef pthread_t celix_thread_t;
+typedef pthread_attr_t celix_thread_attr_t;
+
+typedef void *(*celix_thread_start_t)(void*);
+
+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);
+
+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);
+
+
+
+#endif /* CELIX_THREADS_H_ */



Mime
View raw message