]> rtime.felk.cvut.cz Git - frescor/forb.git/commitdiff
Using plain POSIX instead of FOSA for thread specific data.
authorPetr Benes <benesp16@fel.cvut.cz>
Fri, 28 Jan 2011 17:47:01 +0000 (18:47 +0100)
committerPetr Benes <benesp16@fel.cvut.cz>
Fri, 28 Jan 2011 17:47:01 +0000 (18:47 +0100)
src/executor.c

index 14977b6d07ac0f1ce7957f1a93def562b92b0457..f1a068df6d684e3acd96c79b121d545617d794b8 100644 (file)
 #include "object.h"
 #include <ul_log.h>
 #include <stdio.h>
+#include <pthread.h>
 
 extern UL_LOG_CUST(ulogd_forb_executor);
 
-static int forb_executor_key = -1;
+static pthread_key_t forb_executor_key = -1;
 
 int forb_executor_prepare()
 {
-       return fosa_key_create(&forb_executor_key);
+       return pthread_key_create(&forb_executor_key, NULL);
 }
 
 /** 
@@ -142,10 +143,9 @@ int forb_executor_run(forb_executor_t *executor)
        int ret;
 
        // setting pointer to executor as thread specific data
-       if ((ret = fosa_thread_set_specific_data(forb_executor_key, 
-                                                fosa_thread_self(), executor)))                
+       if ((ret = pthread_setspecific(forb_executor_key, executor)))           
                goto ret;
+       
        fosa_mutex_lock(&executor->mutex);
        while (1) {
                fosa_cond_wait(&executor->new_request_in_empty_list,
@@ -200,11 +200,10 @@ error:
  */
 int forb_get_current_executor(forb_executor_t **executor)
 {
-       int ret;
-       ret = fosa_thread_get_specific_data(forb_executor_key, 
-                                           fosa_thread_self(), ((void *) executor));
+       int ret = 0;
+       *executor = (void *) pthread_getspecific(forb_executor_key);
                                            
-       if (ret)
-               *executor = NULL;
+       if (!(*executor))
+               ret = 1;
        return ret;
 }