controller_entry_t *entry = is_entry ? &global->setting->entry : &global->setting->exit;
controller_entry_action_t *entry_action = 0;
controller_entry_actions_t *entry_actions = 0;
- controller_process_t *process = 0;
// An empty stack is used here because each rule here is the first rule run in the rule's scope.
const f_array_lengths_t stack = f_array_lengths_t_initialize;
}
if (!(global->main->parameters.array[controller_parameter_validate_e].result & f_console_result_found_e)) {
- status = controller_rule_wait_all(*global, is_entry, F_false, process);
+ status = controller_rule_wait_all(*global, is_entry, F_false);
if (F_status_is_error(status)) return status;
}
}
if (global->main->parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) return F_execute;
- controller_thread_process_cancel(*global, is_entry, is_entry ? controller_thread_cancel_execute_e : controller_thread_cancel_exit_execute_e, process);
+ controller_thread_process_cancel(*global, is_entry, is_entry ? controller_thread_cancel_execute_e : controller_thread_cancel_exit_execute_e);
int result = 0;
int option = FL_execute_parameter_option_path_d;
// Check to see if any required processes failed, but do not do this if already operating in failsafe.
if (F_status_is_error_not(status) && !failsafe && !(global->main->parameters.array[controller_parameter_validate_e].result & f_console_result_found_e)) {
- const f_status_t status_wait = controller_rule_wait_all(*global, is_entry, F_true, 0);
+ const f_status_t status_wait = controller_rule_wait_all(*global, is_entry, F_true);
if (F_status_is_error(status_wait)) return status_wait;
if (status_wait == F_require) return F_status_set_error(F_require);
}
#endif // _di_controller_rule_validate_
#ifndef _di_controller_rule_wait_all_
- f_status_t controller_rule_wait_all(const controller_global_t global, const bool is_normal, const bool required, controller_process_t * const caller) {
+ f_status_t controller_rule_wait_all(const controller_global_t global, const bool is_normal, const bool required) {
- f_status_t status_lock = F_none;
-
- if (caller) {
- status_lock = controller_lock_read_process(caller, global.thread, &global.thread->lock.process);
- }
- else {
- status_lock = controller_lock_read(is_normal, global.thread, &global.thread->lock.process);
- }
+ f_status_t status_lock = controller_lock_read(is_normal, global.thread, &global.thread->lock.process);
if (F_status_is_error(status_lock)) {
controller_lock_print_error_critical(global.main->error, F_status_set_fine(status_lock), F_true, global.thread);
for (i = 0; i < process_total; ++i) {
- if (caller) {
- if (!controller_thread_is_enabled_process(caller, global.thread)) break;
- }
- else {
- if (!controller_thread_is_enabled(is_normal, global.thread)) break;
- }
+ if (!controller_thread_is_enabled(is_normal, global.thread)) break;
// Re-establish global process read lock to wait for or protect from the cleanup thread while checking the read process.
- if (caller) {
- status_lock = controller_lock_read_process(caller, global.thread, &global.thread->lock.process);
- }
- else {
- status_lock = controller_lock_read(is_normal, global.thread, &global.thread->lock.process);
- }
-
+ status_lock = controller_lock_read(is_normal, global.thread, &global.thread->lock.process);
if (F_status_is_error(status_lock)) break;
if (!process_list[i]) {
continue;
}
- if (caller) {
- status_lock = controller_lock_read_process(caller, global.thread, &process_list[i]->active);
- }
- else {
- status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->active);
- }
+ status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->active);
if (F_status_is_error(status_lock)) {
f_thread_unlock(&global.thread->lock.process);
// Once the active lock is obtained, then the main process read lock can be safely released.
f_thread_unlock(&global.thread->lock.process);
- if (caller) {
- if (caller) {
- status_lock = controller_lock_read_process(caller, global.thread, &global.thread->lock.rule);
- }
- else {
- status_lock = controller_lock_read(is_normal, global.thread, &global.thread->lock.rule);
- }
-
- if (F_status_is_error(status_lock)) {
- f_thread_unlock(&process_list[i]->active);
-
- break;
- }
-
- if (fl_string_dynamic_compare(caller->rule.alias, process_list[i]->rule.alias) == F_equal_to) {
- f_thread_unlock(&global.thread->lock.rule);
- f_thread_unlock(&process_list[i]->active);
-
- continue;
- }
-
- skip = F_false;
-
- for (j = 0; j < caller->stack.used; ++j) {
-
- if (caller) {
- if (!controller_thread_is_enabled_process(caller, global.thread)) break;
- }
- else {
- if (!controller_thread_is_enabled(is_normal, global.thread)) break;
- }
-
- if (global.thread->processs.array[caller->stack.array[j]] && fl_string_dynamic_compare(process_list[i]->rule.alias, global.thread->processs.array[caller->stack.array[j]]->rule.alias) == F_equal_to) {
- skip = F_true;
- }
-
- if (skip) break;
- } // for
-
- f_thread_unlock(&global.thread->lock.rule);
-
- if (skip) {
- f_thread_unlock(&process_list[i]->active);
-
- continue;
- }
- }
-
- if (caller) {
- status_lock = controller_lock_read_process(caller, global.thread, &process_list[i]->lock);
- }
- else {
- status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->lock);
- }
+ status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->lock);
if (F_status_is_error(status_lock)) {
f_thread_unlock(&process_list[i]->active);
if (process_list[i]->state == controller_process_state_done_e) {
f_thread_unlock(&process_list[i]->lock);
- if (caller) {
- status_lock = controller_lock_write_process(process_list[i], global.thread, &process_list[i]->lock);
- }
- else {
- status_lock = controller_lock_write(is_normal, global.thread, &process_list[i]->lock);
- }
+ status_lock = controller_lock_write(is_normal, global.thread, &process_list[i]->lock);
if (F_status_is_error(status_lock)) {
controller_lock_print_error_critical(global.main->error, F_status_set_fine(status_lock), F_false, global.thread);
f_thread_mutex_unlock(&process_list[i]->wait_lock);
}
- if (caller) {
- status_lock = controller_lock_read_process(caller, global.thread, &process_list[i]->active);
- }
- else {
- status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->active);
- }
+ status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->active);
if (F_status_is_error(status_lock)) {
f_thread_unlock(&process_list[i]->lock);
f_thread_unlock(&process_list[i]->lock);
- if (caller) {
- status_lock = controller_lock_read_process(caller, global.thread, &process_list[i]->lock);
- }
- else {
- status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->lock);
- }
-
+ status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->lock);
if (F_status_is_error(status_lock)) break;
}
break;
}
- if (caller) {
- status_lock = controller_lock_read_process(caller, global.thread, &process_list[i]->lock);
- }
- else {
- status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->lock);
- }
+ status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->lock);
if (F_status_is_error(status_lock)) {
f_thread_unlock(&process_list[i]->active);
return status_lock;
}
- if (caller) {
- if (!controller_thread_is_enabled_process(caller, global.thread)) {
- return F_status_set_error(F_interrupt);
- }
- }
- else {
- if (!controller_thread_is_enabled(is_normal, global.thread)) {
- return F_status_set_error(F_interrupt);
- }
+ if (!controller_thread_is_enabled(is_normal, global.thread)) {
+ return F_status_set_error(F_interrupt);
}
if (F_status_set_fine(status) == F_require) {
#endif // _di_controller_rule_wait_all_
#ifndef _di_controller_rule_wait_all_process_type_
- f_status_t controller_rule_wait_all_process_type(const controller_global_t global, const uint8_t type, const bool required, controller_process_t * const caller) {
+ f_status_t controller_rule_wait_all_process_type(const controller_global_t global, const uint8_t type, const bool required) {
- return controller_rule_wait_all(global, type != controller_process_type_exit_e, required, caller);
+ return controller_rule_wait_all(global, type != controller_process_type_exit_e, required);
}
#endif // _di_controller_rule_wait_all_process_type_
* @param required
* If TRUE, then only process required rules and if a required rule has failed, return.
* If FALSE, process all waits, returning normally (required rules still result in failure).
- * @param caller
- * The process representing the caller so that the process never waits on itself.
- * (optional) set to 0 when calling from a thread that is not running/executing any process.
- * Failure to set this to the process on a thread running/executing a process will likely result in a deadlock.
*
* @return
* F_none on success.
* F_require (with error bit set) if a required process is in failed status when required is TRUE.
*/
#ifndef _di_controller_rule_wait_all_
- extern f_status_t controller_rule_wait_all(const controller_global_t global, const bool is_normal, const bool required, controller_process_t * const caller) F_attribute_visibility_internal_d;
+ extern f_status_t controller_rule_wait_all(const controller_global_t global, const bool is_normal, const bool required) F_attribute_visibility_internal_d;
#endif // _di_controller_rule_wait_all_
/**
* @param required
* If TRUE, then only process required rules and if a required rule has failed, return.
* If FALSE, process all waits, returning normally.
- * @param caller
- * The process representing the caller so that the process never waits on itself.
- * (optional) set to 0 when calling from a thread that is not running/executing any process.
- * Failure to set this to the process on a thread running/executing a process will likely result in a deadlock.
*
* @return
* Success from controller_rule_wait_all().
* @see controller_rule_wait_all()
*/
#ifndef _di_controller_rule_wait_all_process_type_
- extern f_status_t controller_rule_wait_all_process_type(const controller_global_t global, const uint8_t type, const bool required, controller_process_t * const caller) F_attribute_visibility_internal_d;
+ extern f_status_t controller_rule_wait_all_process_type(const controller_global_t global, const uint8_t type, const bool required) F_attribute_visibility_internal_d;
#endif // _di_controller_rule_wait_all_process_type_
#ifdef __cplusplus
#endif // _di_controller_thread_process_
#ifndef _di_controller_thread_process_cancel_
- void controller_thread_process_cancel(const controller_global_t global, const bool is_normal, const uint8_t by, controller_process_t * const caller) {
+ void controller_thread_process_cancel(const controller_global_t global, const bool is_normal, const uint8_t by) {
f_thread_mutex_lock(&global.thread->lock.cancel);
for (; i < global.thread->processs.used; ++i) {
if (!global.thread->processs.array[i]) continue;
- if (caller && i == caller->id) continue;
process = global.thread->processs.array[i];
for (i = 0; i < global.thread->processs.used && lapsed < entry->timeout_exit; ++i) {
if (!global.thread->processs.array[i]) continue;
- if (caller && i == caller->id) continue;
process = global.thread->processs.array[i];
for (i = 0; i < global.thread->processs.size; ++i) {
if (!global.thread->processs.array[i]) continue;
- if (caller && i == caller->id) continue;
process = global.thread->processs.array[i];
global->thread->id_signal = 0;
}
- controller_thread_process_cancel(*global, F_false, controller_thread_cancel_exit_e, 0);
+ controller_thread_process_cancel(*global, F_false, controller_thread_cancel_exit_e);
}
else {
if (F_status_is_error_not(f_thread_mutex_lock(&global->thread->lock.alert))) {