extern UL_LOG_CUST(ulogd_forb_executor);
+int forb_executor_key = -1;
+
/**
* Initializes executor.
*
*/
int forb_executor_run(forb_executor_t *executor)
{
+ int ret;
+
+ // initializing thread specific data (FIXME: maybe should be somewhere else)
+ if (forb_executor_key == -1) {
+ if (ret = fosa_key_create(forb_executor_key))
+ goto ret;
+ }
+ // setting pointer to executor as thread specific data
+ if (ret = fosa_thread_set_specific_data(forb_executor_key,
+ fosa_thread_self(), (void *) executor))
+ goto ret;
+
fosa_mutex_lock(&executor->mutex);
while (1) {
fosa_cond_wait(&executor->new_request_in_empty_list,
}
}
fosa_mutex_unlock(&executor->mutex);
- return 0;
+ret:
+ return ret;
}
/**
error:
return ret;
}
+
+
+/**
+ * Determines the executor we are currently in.
+ *
+ * @param executor Current executor.
+ *
+ * @return Zero in case of success.
+ */
+int forb_get_current_executor(forb_executor_t *executor)
+{
+ int ret;
+ ret = fosa_thread_get_specific_data(forb_executor_key,
+ fosa_thread_self(), &executor);
+ return ret;
+}
ul_list_head_t requests; /**< List of pending requests for this executor. */
} forb_executor_t;
+
int forb_executor_init(forb_executor_t *executor);
void forb_executor_destroy(forb_executor_t *executor);
int forb_executor_register_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);
#endif