Author: pnoltes
Date: Wed Jun  4 20:11:07 2014
New Revision: 1600483

URL: http://svn.apache.org/r1600483
Log:
CELIX-119: removed apr from service_registry. Added (some) celix_thread_attr 
functions to utils. update framework call to service_registry

Modified:
    incubator/celix/trunk/framework/private/include/service_registry_private.h
    incubator/celix/trunk/framework/private/mock/service_registry_mock.c
    incubator/celix/trunk/framework/private/src/framework.c
    incubator/celix/trunk/framework/private/src/service_registry.c
    incubator/celix/trunk/framework/public/include/service_registry.h
    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/service_registry_private.h
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/service_registry_private.h?rev=1600483&r1=1600482&r2=1600483&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/service_registry_private.h 
(original)
+++ incubator/celix/trunk/framework/private/include/service_registry_private.h 
Wed Jun  4 20:11:07 2014
@@ -31,7 +31,6 @@
 #include "service_registry.h"
 
 struct serviceRegistry {
-       apr_pool_t *pool;
        framework_pt framework;
        hash_map_pt serviceRegistrations;
        hash_map_pt serviceReferences;
@@ -41,14 +40,14 @@ struct serviceRegistry {
 
        array_list_pt listenerHooks;
 
-       apr_thread_mutex_t * mutex;
+       celix_thread_mutex_t mutex;
+       celix_thread_mutexattr_t mutexAttr;
 };
 
 struct usageCount {
        unsigned int count;
        service_reference_pt reference;
        void * service;
-       apr_pool_t *pool;
 };
 
 typedef struct usageCount * usage_count_pt;

Modified: incubator/celix/trunk/framework/private/mock/service_registry_mock.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/mock/service_registry_mock.c?rev=1600483&r1=1600482&r2=1600483&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/mock/service_registry_mock.c 
(original)
+++ incubator/celix/trunk/framework/private/mock/service_registry_mock.c Wed 
Jun  4 20:11:07 2014
@@ -37,7 +37,12 @@ celix_status_t serviceRegistry_destroy(s
        return mock_c()->returnValue().value.intValue;
 }
 
-celix_status_t serviceRegistry_getRegisteredServices(service_registry_pt 
registry, apr_pool_t *pool, bundle_pt bundle, array_list_pt *services) {
+celix_status_t serviceRegistry_destroy(service_registry_pt registry) {
+       mock_c()->actualCall("serviceRegistry_destroy");
+       return mock_c()->returnValue().value.intValue;
+}
+
+celix_status_t serviceRegistry_getRegisteredServices(service_registry_pt 
registry, bundle_pt bundle, array_list_pt *services) {
        mock_c()->actualCall("serviceRegistry_getRegisteredServices");
        return mock_c()->returnValue().value.intValue;
 }
@@ -70,7 +75,7 @@ celix_status_t serviceRegistry_unregiste
        return mock_c()->returnValue().value.intValue;
 }
 
-celix_status_t serviceRegistry_getServiceReferences(service_registry_pt 
registry, apr_pool_t *pool, const char *serviceName, filter_pt filter, 
array_list_pt *references) {
+celix_status_t serviceRegistry_getServiceReferences(service_registry_pt 
registry, const char *serviceName, filter_pt filter, array_list_pt *references) 
{
        mock_c()->actualCall("serviceRegistry_getServiceReferences");
        return mock_c()->returnValue().value.intValue;
 }
@@ -101,12 +106,12 @@ service_registration_pt serviceRegistry_
        return mock_c()->returnValue().value.pointerValue;
 }
 
-celix_status_t serviceRegistry_createServiceReference(service_registry_pt 
registry, apr_pool_t *pool, service_registration_pt registration, 
service_reference_pt *reference) {
+celix_status_t serviceRegistry_createServiceReference(service_registry_pt 
registry, service_registration_pt registration, service_reference_pt 
*reference) {
        mock_c()->actualCall("serviceRegistry_createServiceReference");
        return mock_c()->returnValue().value.intValue;
 }
 
-celix_status_t serviceRegistry_getListenerHooks(service_registry_pt registry, 
apr_pool_t *pool, array_list_pt *hooks) {
+celix_status_t serviceRegistry_getListenerHooks(service_registry_pt registry, 
array_list_pt *hooks) {
        mock_c()->actualCall("serviceRegistry_getListenerHooks");
        return mock_c()->returnValue().value.intValue;
 }

Modified: incubator/celix/trunk/framework/private/src/framework.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/framework.c?rev=1600483&r1=1600482&r2=1600483&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/framework.c (original)
+++ incubator/celix/trunk/framework/private/src/framework.c Wed Jun  4 20:11:07 
2014
@@ -382,7 +382,7 @@ celix_status_t fw_init(framework_pt fram
         arrayList_destroy(archives);
     }
 
-    status = CELIX_DO_IF(status, serviceRegistry_create(framework->mp, 
framework, fw_serviceChanged, &framework->registry));
+    status = CELIX_DO_IF(status, serviceRegistry_create(framework, 
fw_serviceChanged, &framework->registry));
     status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, 
framework->bundle, OSGI_FRAMEWORK_BUNDLE_STARTING));
     status = CELIX_DO_IF(status, 
celixThreadCondition_init(&framework->shutdownGate, NULL));
     if (status == CELIX_SUCCESS) {
@@ -1226,12 +1226,13 @@ celix_status_t fw_registerService(framew
 
                 status = CELIX_DO_IF(status, apr_pool_create(&subpool, pool));
 
-                status = CELIX_DO_IF(status, 
serviceRegistry_createServiceReference(framework->registry, subpool, 
*registration, &ref));
+                status = CELIX_DO_IF(status, 
serviceRegistry_createServiceReference(framework->registry, *registration, 
&ref));
                 status = CELIX_DO_IF(status, 
fw_getService(framework,framework->bundle, ref, (void **) &hook));
                 if (status == CELIX_SUCCESS) {
                     hook->added(hook->handle, infos);
                 }
                 status = CELIX_DO_IF(status, 
serviceRegistry_ungetService(framework->registry, framework->bundle, ref, 
&ungetResult));
+                status = CELIX_DO_IF(status, 
serviceRegistry_removeReference(ref));  //NOTE: should this not be done in the 
serviceRegistry_ungetService??
 
                 apr_pool_destroy(subpool);
              }
@@ -1277,7 +1278,7 @@ celix_status_t fw_getServiceReferences(f
         }
        }
 
-       status = CELIX_DO_IF(status, 
serviceRegistry_getServiceReferences(framework->registry, pool, serviceName, 
filter, references));
+       status = CELIX_DO_IF(status, 
serviceRegistry_getServiceReferences(framework->registry, serviceName, filter, 
references));
 
        if (filter != NULL) {
                filter_destroy(filter);
@@ -1311,7 +1312,7 @@ celix_status_t fw_getService(framework_p
 }
 
 celix_status_t fw_getBundleRegisteredServices(framework_pt framework, 
apr_pool_t *pool, bundle_pt bundle, array_list_pt *services) {
-       return serviceRegistry_getRegisteredServices(framework->registry, pool, 
bundle, services);
+       return serviceRegistry_getRegisteredServices(framework->registry, 
bundle, services);
 }
 
 celix_status_t fw_getBundleServicesInUse(framework_pt framework, bundle_pt 
bundle, array_list_pt *services) {
@@ -1354,7 +1355,7 @@ void fw_addServiceListener(framework_pt 
        arrayList_add(framework->serviceListeners, fwListener);
 
        apr_pool_create(&subpool, listener->pool);
-       serviceRegistry_getListenerHooks(framework->registry, subpool, 
&listenerHooks);
+       serviceRegistry_getListenerHooks(framework->registry, &listenerHooks);
 
        info = (listener_hook_info_pt) apr_palloc(subpool, sizeof(*info));
 
@@ -1421,7 +1422,7 @@ void fw_removeServiceListener(framework_
        if (info != NULL) {
                unsigned int i;
                array_list_pt listenerHooks = NULL;
-               serviceRegistry_getListenerHooks(framework->registry, pool, 
&listenerHooks);
+               serviceRegistry_getListenerHooks(framework->registry, 
&listenerHooks);
                
                for (i = 0; i < arrayList_size(listenerHooks); i++) {
                        service_reference_pt ref = (service_reference_pt) 
arrayList_get(listenerHooks, i);
@@ -1544,12 +1545,15 @@ void fw_serviceChanged(framework_pt fram
 
                                event = (service_event_pt) apr_palloc(spool, 
sizeof(*event));
 
-                               
serviceRegistry_createServiceReference(framework->registry, spool, 
registration, &reference);
+                               
serviceRegistry_createServiceReference(framework->registry, registration, 
&reference);
 
                                event->type = eventType;
                                event->reference = reference;
 
                                
element->listener->serviceChanged(element->listener, event);
+
+                               //TODO cleanup service reference
+
                        } else if (eventType == 
OSGI_FRAMEWORK_SERVICE_EVENT_MODIFIED) {
                                bool matchResult = false;
                                int matched = 0;
@@ -1561,11 +1565,13 @@ void fw_serviceChanged(framework_pt fram
                                        service_reference_pt reference = NULL;
                                        service_event_pt endmatch = 
(service_event_pt) malloc(sizeof(*endmatch));
 
-                                       
serviceRegistry_createServiceReference(framework->registry, 
element->listener->pool, registration, &reference);
+                                       
serviceRegistry_createServiceReference(framework->registry, registration, 
&reference);
 
                                        endmatch->reference = reference;
                                        endmatch->type = 
OSGI_FRAMEWORK_SERVICE_EVENT_MODIFIED_ENDMATCH;
                                        
element->listener->serviceChanged(element->listener, endmatch);
+
+                                       //TODO clean up serviceReference after 
serviceChanged update
                                }
                        }
                }

Modified: incubator/celix/trunk/framework/private/src/service_registry.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/service_registry.c?rev=1600483&r1=1600482&r2=1600483&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_registry.c (original)
+++ incubator/celix/trunk/framework/private/src/service_registry.c Wed Jun  4 
20:11:07 2014
@@ -36,27 +36,18 @@
 #include "framework_private.h"
 #include "celix_log.h"
 
-apr_status_t serviceRegistry_destroy(void *handle);
-
 celix_status_t serviceRegistry_registerServiceInternal(service_registry_pt 
registry, bundle_pt bundle, char * serviceName, void * serviceObject, 
properties_pt dictionary, bool isFactory, service_registration_pt 
*registration);
 celix_status_t serviceRegistry_addHooks(service_registry_pt registry, char 
*serviceName, void *serviceObject, service_registration_pt registration);
 celix_status_t serviceRegistry_removeHook(service_registry_pt registry, 
service_registration_pt registration);
 
-celix_status_t serviceRegistry_create(apr_pool_t *ppool, framework_pt 
framework, serviceChanged_function_pt serviceChanged, service_registry_pt 
*registry) {
+celix_status_t serviceRegistry_create(framework_pt framework, 
serviceChanged_function_pt serviceChanged, service_registry_pt *registry) {
        celix_status_t status = CELIX_SUCCESS;
-       apr_pool_t *pool = NULL;
-
-       apr_pool_create(&pool, ppool);
 
-       *registry = (service_registry_pt) apr_palloc(pool, 
(sizeof(**registry)));
+       *registry = malloc(sizeof(**registry));
        if (!*registry) {
                status = CELIX_ENOMEM;
        } else {
-               apr_status_t aprStatus;
 
-               apr_pool_pre_cleanup_register(pool, *registry, 
serviceRegistry_destroy);
-
-               (*registry)->pool=pool;
                (*registry)->serviceChanged = serviceChanged;
                (*registry)->inUseMap = hashMap_create(NULL, NULL, NULL, NULL);
                (*registry)->serviceRegistrations = hashMap_create(NULL, NULL, 
NULL, NULL);
@@ -64,10 +55,12 @@ celix_status_t serviceRegistry_create(ap
                (*registry)->currentServiceId = 1l;
 
                arrayList_create(&(*registry)->listenerHooks);
-               aprStatus = apr_thread_mutex_create(&(*registry)->mutex, 
APR_THREAD_MUTEX_NESTED, pool);
-               if (aprStatus != APR_SUCCESS) {
-                       status = CELIX_FRAMEWORK_EXCEPTION;
-               }
+
+               celix_thread_mutexattr_t attr;
+
+               status = celixThreadMutexAttr_create(&(*registry)->mutexAttr);
+               status = CELIX_DO_IF(status, 
celixThreadMutexAttr_settype(&(*registry)->mutexAttr, 
CELIX_THREAD_MUTEX_RECURSIVE));
+               status = CELIX_DO_IF(status, 
celixThreadMutex_create(&(*registry)->mutex, &(*registry)->mutexAttr));
        }
 
        framework_logIfError(logger, status, NULL, "Cannot create service 
registry");
@@ -75,17 +68,15 @@ celix_status_t serviceRegistry_create(ap
        return status;
 }
 
-apr_status_t serviceRegistry_destroy(void *handle) {
-       service_registry_pt registry = (service_registry_pt) handle;
+apr_status_t serviceRegistry_destroy(service_registry_pt registry) {
     hashMap_destroy(registry->inUseMap, false, false);
     hashMap_destroy(registry->serviceRegistrations, false, false);
     arrayList_destroy(registry->listenerHooks);
-    apr_thread_mutex_destroy(registry->mutex);
+    celixThreadMutex_destroy(&registry->mutex);
+    celixThreadMutexAttr_destroy(&registry->mutexAttr);
     registry->framework = NULL;
     registry->inUseMap = NULL;
     registry->listenerHooks = NULL;
-    registry->mutex = NULL;
-    registry->pool = NULL;
     registry->serviceChanged = NULL;
     registry->serviceReferences = NULL;
     registry->serviceRegistrations = NULL;
@@ -115,16 +106,11 @@ celix_status_t serviceRegistry_getUsageC
 }
 
 celix_status_t serviceRegistry_addUsageCount(service_registry_pt registry, 
bundle_pt bundle, service_reference_pt reference, usage_count_pt *usageCount) {
-       apr_pool_t *pool = NULL;
-
-       apr_pool_create(&pool, registry->pool);
-
        array_list_pt usages = hashMap_get(registry->inUseMap, bundle);
-       usage_count_pt usage = (usage_count_pt) apr_palloc(pool, 
sizeof(*usage));
+       usage_count_pt usage = malloc(sizeof(*usage));
        usage->reference = reference;
        usage->count = 0;
        usage->service = NULL;
-       usage->pool = pool;
 
        if (usages == NULL) {
                module_pt mod = NULL;
@@ -145,7 +131,7 @@ celix_status_t serviceRegistry_flushUsag
                        usage_count_pt usage = arrayListIterator_next(iter);
                        if (usage->reference == reference) {
                                arrayListIterator_remove(iter);
-                               apr_pool_destroy(usage->pool);
+                               free(usage);
                        }
                }
                arrayListIterator_destroy(iter);
@@ -159,7 +145,7 @@ celix_status_t serviceRegistry_flushUsag
        return CELIX_SUCCESS;
 }
 
-celix_status_t serviceRegistry_getRegisteredServices(service_registry_pt 
registry, apr_pool_t *pool, bundle_pt bundle, array_list_pt *services) {
+celix_status_t serviceRegistry_getRegisteredServices(service_registry_pt 
registry, bundle_pt bundle, array_list_pt *services) {
        celix_status_t status = CELIX_SUCCESS;
 
        array_list_pt regs = (array_list_pt) 
hashMap_get(registry->serviceRegistrations, bundle);
@@ -171,7 +157,7 @@ celix_status_t serviceRegistry_getRegist
                        service_registration_pt reg = arrayList_get(regs, i);
                        if (serviceRegistration_isValid(reg)) {
                                service_reference_pt reference = NULL;
-                               status = 
serviceRegistry_createServiceReference(registry, pool, reg, &reference);
+                               status = 
serviceRegistry_createServiceReference(registry, reg, &reference);
                                if (status == CELIX_SUCCESS) {
                                        arrayList_add(*services, reference);
                                }
@@ -195,7 +181,7 @@ celix_status_t serviceRegistry_registerS
 celix_status_t serviceRegistry_registerServiceInternal(service_registry_pt 
registry, bundle_pt bundle, char * serviceName, void * serviceObject, 
properties_pt dictionary, bool isFactory, service_registration_pt 
*registration) {
        array_list_pt regs;
        apr_pool_t *pool = NULL;
-       apr_thread_mutex_lock(registry->mutex);
+       celixThreadMutex_lock(&registry->mutex);
 
        bundle_getMemoryPool(bundle, &pool);
 
@@ -215,7 +201,7 @@ celix_status_t serviceRegistry_registerS
        arrayList_add(regs, *registration);
        hashMap_put(registry->serviceRegistrations, bundle, regs);
 
-       apr_thread_mutex_unlock(registry->mutex);
+       celixThreadMutex_unlock(&registry->mutex);
 
        if (registry->serviceChanged != NULL) {
 //             service_event_pt event = (service_event_pt) 
malloc(sizeof(*event));
@@ -235,7 +221,7 @@ celix_status_t serviceRegistry_unregiste
        array_list_pt regs;
        array_list_pt references = NULL;
 
-       apr_thread_mutex_lock(registry->mutex);
+       celixThreadMutex_lock(&registry->mutex);
 
        serviceRegistry_removeHook(registry, registration);
 
@@ -245,23 +231,21 @@ celix_status_t serviceRegistry_unregiste
                hashMap_put(registry->serviceRegistrations, bundle, regs);
        }
 
-       apr_thread_mutex_unlock(registry->mutex);
+       celixThreadMutex_unlock(&registry->mutex);
 
        if (registry->serviceChanged != NULL) {
                registry->serviceChanged(registry->framework, 
OSGI_FRAMEWORK_SERVICE_EVENT_UNREGISTERING, registration, NULL);
        }
 
-       apr_thread_mutex_lock(registry->mutex);
+       celixThreadMutex_lock(&registry->mutex);
        // unget service
 
        serviceRegistration_getServiceReferences(registration, &references);
        for (i = 0; i < arrayList_size(references); i++) {
                service_reference_pt reference = (service_reference_pt) 
arrayList_get(references, i);
-               apr_pool_t *pool = NULL;
                array_list_pt clients = NULL;
                unsigned int j;
 
-               apr_pool_create(&pool, registry->pool);
                clients = serviceRegistry_getUsingBundles(registry, reference);
                for (j = 0; (clients != NULL) && (j < arrayList_size(clients)); 
j++) {
                        bundle_pt client = (bundle_pt) arrayList_get(clients, 
j);
@@ -271,7 +255,6 @@ celix_status_t serviceRegistry_unregiste
                        }
                }
                arrayList_destroy(clients);
-               apr_pool_destroy(pool);
 
                serviceReference_invalidate(reference);
        }
@@ -279,7 +262,7 @@ celix_status_t serviceRegistry_unregiste
 
        serviceRegistration_destroy(registration);
 
-       apr_thread_mutex_unlock(registry->mutex);
+       celixThreadMutex_unlock(&registry->mutex);
 
        return CELIX_SUCCESS;
 }
@@ -287,9 +270,9 @@ celix_status_t serviceRegistry_unregiste
 celix_status_t serviceRegistry_unregisterServices(service_registry_pt 
registry, bundle_pt bundle) {
        array_list_pt regs = NULL;
        unsigned int i;
-       apr_thread_mutex_lock(registry->mutex);
+       celixThreadMutex_lock(&registry->mutex);
        regs = (array_list_pt) hashMap_get(registry->serviceRegistrations, 
bundle);
-       apr_thread_mutex_unlock(registry->mutex);
+       celixThreadMutex_unlock(&registry->mutex);
        
        for (i = 0; (regs != NULL) && i < arrayList_size(regs); i++) {
                service_registration_pt reg = arrayList_get(regs, i);
@@ -304,15 +287,15 @@ celix_status_t serviceRegistry_unregiste
                removed = NULL;
        }
 
-       apr_thread_mutex_lock(registry->mutex);
+       celixThreadMutex_lock(&registry->mutex);
        hashMap_remove(registry->serviceRegistrations, bundle);
-       apr_thread_mutex_unlock(registry->mutex);
+       celixThreadMutex_unlock(&registry->mutex);
 
        return CELIX_SUCCESS;
 }
 
 
-celix_status_t serviceRegistry_createServiceReference(service_registry_pt 
registry, apr_pool_t *pool, service_registration_pt registration, 
service_reference_pt *reference) {
+celix_status_t serviceRegistry_createServiceReference(service_registry_pt 
registry, service_registration_pt registration, service_reference_pt 
*reference) {
        celix_status_t status = CELIX_SUCCESS;
 
        bundle_pt bundle = NULL;
@@ -329,7 +312,7 @@ celix_status_t serviceRegistry_createSer
        return status;
 }
 
-celix_status_t serviceRegistry_getServiceReferences(service_registry_pt 
registry, apr_pool_t *pool, const char *serviceName, filter_pt filter, 
array_list_pt *references) {
+celix_status_t serviceRegistry_getServiceReferences(service_registry_pt 
registry, const char *serviceName, filter_pt filter, array_list_pt *references) 
{
        celix_status_t status = CELIX_SUCCESS;
        hash_map_values_pt registrations;
        hash_map_iterator_pt iterator;
@@ -367,7 +350,7 @@ celix_status_t serviceRegistry_getServic
                                if (matched) {
                                        if 
(serviceRegistration_isValid(registration)) {
                                                service_reference_pt reference 
= NULL;
-                                               
serviceRegistry_createServiceReference(registry, pool, registration, 
&reference);
+                                               
serviceRegistry_createServiceReference(registry, registration, &reference);
                                                arrayList_add(*references, 
reference);
                                        }
                                }
@@ -416,7 +399,7 @@ celix_status_t serviceRegistry_getServic
        usage_count_pt usage = NULL;
        serviceReference_getServiceRegistration(reference, &registration);
        
-       apr_thread_mutex_lock(registry->mutex);
+       celixThreadMutex_lock(&registry->mutex);
 
        if (serviceRegistration_isValid(registration)) {
                status = serviceRegistry_getUsageCount(registry, bundle, 
reference, &usage);
@@ -426,18 +409,18 @@ celix_status_t serviceRegistry_getServic
                usage->count++;
                *service = usage->service;
        }
-       apr_thread_mutex_unlock(registry->mutex);
+       celixThreadMutex_unlock(&registry->mutex);
 
        if ((usage != NULL) && (*service == NULL)) {
                serviceRegistration_getService(registration, bundle, service);
        }
-       apr_thread_mutex_lock(registry->mutex);
+       celixThreadMutex_lock(&registry->mutex);
        if ((!serviceRegistration_isValid(registration)) || (*service == NULL)) 
{
                serviceRegistry_flushUsageCount(registry, bundle, reference);
        } else {
                usage->service = *service;
        }
-       apr_thread_mutex_unlock(registry->mutex);
+       celixThreadMutex_unlock(&registry->mutex);
 
        return CELIX_SUCCESS;
 }
@@ -448,11 +431,11 @@ celix_status_t serviceRegistry_ungetServ
        usage_count_pt usage = NULL;
        serviceReference_getServiceRegistration(reference, &registration);
        
-       apr_thread_mutex_lock(registry->mutex);
+       celixThreadMutex_lock(&registry->mutex);
 
        status = serviceRegistry_getUsageCount(registry, bundle, reference, 
&usage);
        if (usage == NULL) {
-               apr_thread_mutex_unlock(registry->mutex);
+               celixThreadMutex_unlock(&registry->mutex);
                *result = false;
                return CELIX_SUCCESS;
        }
@@ -465,7 +448,7 @@ celix_status_t serviceRegistry_ungetServ
                serviceRegistry_flushUsageCount(registry, bundle, reference);
        }
 
-       apr_thread_mutex_unlock(registry->mutex);
+       celixThreadMutex_unlock(&registry->mutex);
 
        *result = true;
 
@@ -480,9 +463,9 @@ void serviceRegistry_ungetServices(servi
        apr_pool_t *pool = NULL;
        bundle_getMemoryPool(bundle, &pool);
 
-       apr_thread_mutex_lock(registry->mutex);
+       celixThreadMutex_lock(&registry->mutex);
        usages = hashMap_get(registry->inUseMap, bundle);
-       apr_thread_mutex_unlock(registry->mutex);
+       celixThreadMutex_unlock(&registry->mutex);
 
        if (usages == NULL || arrayList_isEmpty(usages)) {
                return;
@@ -548,7 +531,7 @@ celix_status_t serviceRegistry_removeHoo
        return status;
 }
 
-celix_status_t serviceRegistry_getListenerHooks(service_registry_pt registry, 
apr_pool_t *pool, array_list_pt *hooks) {
+celix_status_t serviceRegistry_getListenerHooks(service_registry_pt registry, 
array_list_pt *hooks) {
        celix_status_t status = CELIX_SUCCESS;
 
        if (registry == NULL || *hooks != NULL) {
@@ -560,7 +543,7 @@ celix_status_t serviceRegistry_getListen
                        for (i = 0; i < 
arrayList_size(registry->listenerHooks); i++) {
                                service_registration_pt registration = 
arrayList_get(registry->listenerHooks, i);
                                service_reference_pt reference = NULL;
-                               
serviceRegistry_createServiceReference(registry, pool, registration, 
&reference);
+                               
serviceRegistry_createServiceReference(registry, registration, &reference);
                                arrayList_add(*hooks, reference);
                        }
                }

Modified: incubator/celix/trunk/framework/public/include/service_registry.h
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/public/include/service_registry.h?rev=1600483&r1=1600482&r2=1600483&view=diff
==============================================================================
--- incubator/celix/trunk/framework/public/include/service_registry.h (original)
+++ incubator/celix/trunk/framework/public/include/service_registry.h Wed Jun  
4 20:11:07 2014
@@ -27,8 +27,6 @@
 #ifndef SERVICE_REGISTRY_H_
 #define SERVICE_REGISTRY_H_
 
-#include <apr_general.h>
-
 typedef struct serviceRegistry * service_registry_pt;
 
 #include "properties.h"
@@ -40,24 +38,26 @@ typedef struct serviceRegistry * service
 
 typedef void (*serviceChanged_function_pt)(framework_pt, service_event_type_e, 
service_registration_pt, properties_pt);
 
-celix_status_t serviceRegistry_create(apr_pool_t *pool, framework_pt 
framework, serviceChanged_function_pt serviceChanged, service_registry_pt 
*registry);
-celix_status_t serviceRegistry_getRegisteredServices(service_registry_pt 
registry, apr_pool_t *pool, bundle_pt bundle, array_list_pt *services);
+celix_status_t serviceRegistry_create(framework_pt framework, 
serviceChanged_function_pt serviceChanged, service_registry_pt *registry);
+celix_status_t serviceRegistry_destroy(service_registry_pt registry);
+
+celix_status_t serviceRegistry_getRegisteredServices(service_registry_pt 
registry, bundle_pt bundle, array_list_pt *services);
 celix_status_t serviceRegistry_getServicesInUse(service_registry_pt registry, 
bundle_pt bundle, array_list_pt *services);
 celix_status_t serviceRegistry_registerService(service_registry_pt registry, 
bundle_pt bundle, char * serviceName, void * serviceObject, properties_pt 
dictionary, service_registration_pt *registration);
 celix_status_t serviceRegistry_registerServiceFactory(service_registry_pt 
registry, bundle_pt bundle, char * serviceName, service_factory_pt factory, 
properties_pt dictionary, service_registration_pt *registration);
 celix_status_t serviceRegistry_unregisterService(service_registry_pt registry, 
bundle_pt bundle, service_registration_pt registration);
 celix_status_t serviceRegistry_unregisterServices(service_registry_pt 
registry, bundle_pt bundle);
-celix_status_t serviceRegistry_getServiceReferences(service_registry_pt 
registry, apr_pool_t *pool, const char *serviceName, filter_pt filter, 
array_list_pt *references);
+celix_status_t serviceRegistry_getServiceReferences(service_registry_pt 
registry, const char *serviceName, filter_pt filter, array_list_pt *references);
 celix_status_t serviceRegistry_getService(service_registry_pt registry, 
bundle_pt bundle, service_reference_pt reference, void **service);
 celix_status_t serviceRegistry_ungetService(service_registry_pt registry, 
bundle_pt bundle, service_reference_pt reference, bool *result);
 void serviceRegistry_ungetServices(service_registry_pt registry, bundle_pt 
bundle);
 array_list_pt serviceRegistry_getUsingBundles(service_registry_pt registry, 
service_reference_pt reference);
 service_registration_pt serviceRegistry_findRegistration(service_registry_pt 
registry, service_reference_pt reference);
 
-celix_status_t serviceRegistry_createServiceReference(service_registry_pt 
registry, apr_pool_t *pool, service_registration_pt registration, 
service_reference_pt *reference);
+celix_status_t serviceRegistry_createServiceReference(service_registry_pt 
registry, service_registration_pt registration, service_reference_pt 
*reference);
 celix_status_t serviceRegistry_removeReference(service_reference_pt reference);
 
-celix_status_t serviceRegistry_getListenerHooks(service_registry_pt registry, 
apr_pool_t *pool, array_list_pt *hooks);
+celix_status_t serviceRegistry_getListenerHooks(service_registry_pt registry, 
array_list_pt *hooks);
 
 celix_status_t serviceRegistry_servicePropertiesModified(service_registry_pt 
registry, service_registration_pt registration, properties_pt oldprops);
 

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=1600483&r1=1600482&r2=1600483&view=diff
==============================================================================
--- incubator/celix/trunk/utils/private/src/celix_threads.c (original)
+++ incubator/celix/trunk/utils/private/src/celix_threads.c Wed Jun  4 20:11:07 
2014
@@ -68,6 +68,34 @@ celix_status_t celixThreadMutex_unlock(c
     return pthread_mutex_unlock(mutex);
 }
 
+celix_status_t celixThreadMutexAttr_create(celix_thread_mutexattr_t *attr) {
+       return pthread_mutexattr_init(attr);
+}
+
+celix_status_t celixThreadMutexAttr_destroy(celix_thread_mutexattr_t *attr) {
+       return pthread_mutexattr_destroy(attr);
+}
+
+celix_status_t celixThreadMutexAttr_settype(celix_thread_mutexattr_t *attr, 
int type) {
+       celix_status_t status = CELIX_SUCCESS;
+       switch(type) {
+               case CELIX_THREAD_MUTEX_NORMAL :
+                       status =pthread_mutexattr_settype(attr, 
PTHREAD_MUTEX_NORMAL);
+                       break;
+               case CELIX_THREAD_MUTEX_RECURSIVE :
+                       status= pthread_mutexattr_settype(attr, 
PTHREAD_MUTEX_RECURSIVE);
+                       break;
+               case CELIX_THREAD_MUTEX_ERRORCHECK :
+                       status = pthread_mutexattr_settype(attr, 
PTHREAD_MUTEX_ERRORCHECK);
+                       break;
+               case CELIX_THREAD_MUTEX_DEFAULT :
+                       status = pthread_mutexattr_settype(attr, 
PTHREAD_MUTEX_DEFAULT);
+                       break;
+               default:
+                       status = pthread_mutexattr_settype(attr, 
PTHREAD_MUTEX_DEFAULT);
+       }
+}
+
 celix_status_t celixThreadCondition_init(celix_thread_cond_t *condition, 
celix_thread_condattr_t *attr) {
     return pthread_cond_init(condition, attr);
 }
@@ -83,7 +111,3 @@ celix_status_t celixThreadCondition_broa
 celix_status_t celixThreadCondition_signal(celix_thread_cond_t *cond) {
     return pthread_cond_signal(cond);
 }
-
-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=1600483&r1=1600482&r2=1600483&view=diff
==============================================================================
--- incubator/celix/trunk/utils/public/include/celix_threads.h (original)
+++ incubator/celix/trunk/utils/public/include/celix_threads.h Wed Jun  4 
20:11:07 2014
@@ -46,11 +46,25 @@ int celixThread_equals(celix_thread_t th
 typedef pthread_mutex_t celix_thread_mutex_t;
 typedef pthread_mutexattr_t celix_thread_mutexattr_t;
 
+//MUTEX TYPES
+enum {
+       CELIX_THREAD_MUTEX_NORMAL,
+       CELIX_THREAD_MUTEX_RECURSIVE,
+       CELIX_THREAD_MUTEX_ERRORCHECK,
+       CELIX_THREAD_MUTEX_DEFAULT
+};
+
+
 celix_status_t celixThreadMutex_create(celix_thread_mutex_t *mutex, 
celix_thread_mutexattr_t *attr);
 celix_status_t celixThreadMutex_destroy(celix_thread_mutex_t *mutex);
 celix_status_t celixThreadMutex_lock(celix_thread_mutex_t *mutex);
 celix_status_t celixThreadMutex_unlock(celix_thread_mutex_t *mutex);
 
+celix_status_t celixThreadMutexAttr_create(celix_thread_mutexattr_t *attr);
+celix_status_t celixThreadMutexAttr_destroy(celix_thread_mutexattr_t *attr);
+celix_status_t celixThreadMutexAttr_settype(celix_thread_mutexattr_t *attr, 
int type);
+
+
 typedef pthread_cond_t celix_thread_cond_t;
 typedef pthread_condattr_t celix_thread_condattr_t;
 
@@ -58,6 +72,5 @@ celix_status_t celixThreadCondition_init
 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_ */


Reply via email to