]> rtime.felk.cvut.cz Git - frescor/forb.git/commitdiff
Simplify frob_get_current_executor()
authorMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 8 Feb 2011 16:40:54 +0000 (17:40 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 8 Feb 2011 16:40:54 +0000 (17:40 +0100)
Return the executor as return value and not via a parameter.

src/executor.c
src/executor.h
src/tests/executor_id.c

index f1a068df6d684e3acd96c79b121d545617d794b8..9e725d012a2a7b6b72c6a7dc9f54a591b5c7b095 100644 (file)
@@ -194,16 +194,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 = 0;
-       *executor = (void *) pthread_getspecific(forb_executor_key);
-                                           
-       if (!(*executor))
-               ret = 1;
-       return ret;
+       return pthread_getspecific(forb_executor_key);
 }
index 06dddcddcd5bf93bb0f7ae4eb444df41948624a3..8f9864ebd8bb91a6132ee7f0715a9f6e8f3cf82a 100644 (file)
@@ -85,6 +85,6 @@ void forb_executor_unregister_object(forb_executor_t *executor, forb_object obj)
 int forb_executor_run(forb_executor_t *executor);
 
 int forb_execute_object(forb_object obj);
-int forb_get_current_executor(forb_executor_t **executor);
+forb_executor_t *forb_get_current_executor(void);
 
 #endif
index 1aace5b1e0f11a39294d8e0b600b99b34754ea57..fadee53574ae0e404b88f3de481e2d383f6b14d9 100644 (file)
@@ -84,7 +84,7 @@ int main(int argc, char *argv[])
        }
 
        // ------------------------------------------------------
-       if (forb_get_current_executor(&executor)) {
+       if ((executor = forb_get_current_executor())) {
                printf("Test: Error while getting current executor\n");
                if (executor == NULL)
                printf("Test: Executor: NULL\n");