forb_exec_req_nolock_init_head(executor);
forb_syncobj_init(&executor->reply_processed, 0);
+
+ executor->finish = false;
+ fosa_cond_init(&executor->finished);
return 0;
}
/* TODO: */
}
+/**
+ * Waits for the executor to finish processing requests.
+ *
+ * @param executor
+ */
+void forb_executor_synchronize(forb_executor_t *executor)
+{
+ fosa_mutex_lock(&executor->mutex);
+ executor->finish = true;
+ fosa_cond_signal(&executor->new_request_in_empty_list);
+ fosa_cond_wait(&executor->finished, &executor->mutex);
+ fosa_mutex_unlock(&executor->mutex);
+
+}
+
/**
* Setup the object @a obj so that requests to it are executed within
* the thread of the @a executor.
fosa_mutex_lock(&executor->mutex);
while (1) {
- fosa_cond_wait(&executor->new_request_in_empty_list,
- &executor->mutex);
while (!forb_exec_req_nolock_is_empty(executor)) {
forb_exec_req_t *exec_req;
exec_req = forb_exec_req_nolock_cut_first(executor);
fosa_mutex_lock(&executor->mutex);
}
+ if (executor->finish) {
+ fosa_cond_broadcast(&executor->finished);
+ executor->finish = false;
+ }
+
+
+ fosa_cond_wait(&executor->new_request_in_empty_list,
+ &executor->mutex);
}
fosa_mutex_unlock(&executor->mutex);
ret: