]> rtime.felk.cvut.cz Git - frescor/forb.git/blobdiff - src/executor.c
Merge branch 'master' of rtime.felk.cvut.cz:/frescor/frsh-forb
[frescor/forb.git] / src / executor.c
index 14977b6d07ac0f1ce7957f1a93def562b92b0457..7af1923975a17d4e479a24ddbbb21c66ae4f1816 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);
 }
 
 /** 
@@ -85,6 +86,8 @@ int forb_executor_init(forb_executor_t *executor)
        if (ret) return ret;
 
        forb_exec_req_nolock_init_head(executor);
+       
+       forb_syncobj_init(&executor->reply_processed, 0);
        return 0;
 }
 
@@ -142,10 +145,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,
@@ -194,17 +196,10 @@ error:
 /**
  * Determines the executor we are currently in.
  *
- * @param executor Current executor pointer.
- *
- * @return Zero in case of success.
+ * @return Pointer to the current executor or NULL if not called
+ * within executor.
  */
-int forb_get_current_executor(forb_executor_t **executor)
+forb_executor_t *forb_get_current_executor(void)
 {
-       int ret;
-       ret = fosa_thread_get_specific_data(forb_executor_key, 
-                                           fosa_thread_self(), ((void *) executor));
-                                           
-       if (ret)
-               *executor = NULL;
-       return ret;
+       return pthread_getspecific(forb_executor_key);
 }