From: Kevin Day Date: Wed, 8 Jun 2022 04:44:27 +0000 (-0500) Subject: Update: Rename f_thread_signal() to f_thread_signal_write(). X-Git-Tag: 0.5.10~57 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=7dc358d5e88b07bc329ef12990b106ab645b1654;p=fll Update: Rename f_thread_signal() to f_thread_signal_write(). I feel this function name should be more explicit. That is, it should avoid confusion between read and write operations. --- diff --git a/level_0/f_thread/c/thread.c b/level_0/f_thread/c/thread.c index 22b0a98..4aa5442 100644 --- a/level_0/f_thread/c/thread.c +++ b/level_0/f_thread/c/thread.c @@ -2984,8 +2984,25 @@ extern "C" { } #endif // _di_f_thread_sets_resize_ -#ifndef _di_f_thread_signal_ - f_status_t f_thread_signal(const f_thread_id_t id, const int signal) { +#ifndef _di_f_thread_signal_mask_ + f_status_t f_thread_signal_mask(const int how, const sigset_t *next, sigset_t * const current) { + #ifndef _di_level_0_parameter_checking_ + if (!next && !current) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (pthread_sigmask(how, next, current) < 0) { + if (errno == EFAULT) return F_status_set_error(F_buffer); + if (errno == EINVAL) return F_status_set_error(F_parameter); + + return F_status_set_error(F_failure); + } + + return F_none; + } +#endif // _di_f_thread_signal_mask_ + +#ifndef _di_f_thread_signal_write_ + f_status_t f_thread_signal_write(const f_thread_id_t id, const int signal) { const int error = pthread_kill(id, signal); @@ -3007,24 +3024,7 @@ extern "C" { return F_found; } -#endif // _di_f_thread_signal_ - -#ifndef _di_f_thread_signal_mask_ - f_status_t f_thread_signal_mask(const int how, const sigset_t *next, sigset_t * const current) { - #ifndef _di_level_0_parameter_checking_ - if (!next && !current) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (pthread_sigmask(how, next, current) < 0) { - if (errno == EFAULT) return F_status_set_error(F_buffer); - if (errno == EINVAL) return F_status_set_error(F_parameter); - - return F_status_set_error(F_failure); - } - - return F_none; - } -#endif // _di_f_thread_signal_mask_ +#endif // _di_f_thread_signal_write_ #if defined(_pthread_sigqueue_unsupported_) && !defined(_di_f_thread_signal_queue_) f_status_t f_thread_signal_queue(const f_thread_id_t id, const int signal, const union sigval value) { diff --git a/level_0/f_thread/c/thread.h b/level_0/f_thread/c/thread.h index 8f57143..3334c83 100644 --- a/level_0/f_thread/c/thread.h +++ b/level_0/f_thread/c/thread.h @@ -3983,29 +3983,6 @@ extern "C" { #endif // _di_f_thread_sets_resize_ /** - * Send a signal to the given thread. - * - * @param id - * The ID of the thread to signal. - * @param signal - * The signal to send to the thread. - * If 0 is used instead of a valid signal, then instead check to see if the thread exists. - * - * @return - * F_none on success and signal is not 0. - * F_found on success, signal is 0, and the thread by the given ID does exist. - * - * F_found_not on success, signal is 0, and the thread by the given ID does not exist. - * F_found_not (with error bit) if no thread by the given ID was found (and signal is not 0). - * F_parameter (with error bit) if a parameter is invalid. - * - * @see pthread_kill() - */ -#ifndef _di_f_thread_signal_ - extern f_status_t f_thread_signal(const f_thread_id_t id, const int signal); -#endif // _di_f_thread_signal_ - -/** * Get or assign the current signal set in use. * * Either set or previous may be NULL but not both (at least one is required). @@ -4034,6 +4011,29 @@ extern "C" { #endif // _di_f_thread_signal_mask_ /** + * Send a signal to the given thread. + * + * @param id + * The ID of the thread to signal. + * @param signal + * The signal to send to the thread. + * If 0 is used instead of a valid signal, then instead check to see if the thread exists. + * + * @return + * F_none on success and signal is not 0. + * F_found on success, signal is 0, and the thread by the given ID does exist. + * + * F_found_not on success, signal is 0, and the thread by the given ID does not exist. + * F_found_not (with error bit) if no thread by the given ID was found (and signal is not 0). + * F_parameter (with error bit) if a parameter is invalid. + * + * @see pthread_kill() + */ +#ifndef _di_f_thread_signal_write_ + extern f_status_t f_thread_signal_write(const f_thread_id_t id, const int signal); +#endif // _di_f_thread_signal_write_ + +/** * Send the signal and value to the given thread. * * @param id diff --git a/level_3/controller/c/common/private-process.c b/level_3/controller/c/common/private-process.c index a584626..aa70c85 100644 --- a/level_3/controller/c/common/private-process.c +++ b/level_3/controller/c/common/private-process.c @@ -46,7 +46,7 @@ extern "C" { void controller_process_delete_simple(controller_process_t * const process) { if (process->id_thread) { - f_thread_signal(process->id_thread, F_signal_kill); + f_thread_signal_write(process->id_thread, F_signal_kill); f_thread_join(process->id_thread, 0); process->id_thread = 0; diff --git a/level_3/controller/c/thread/private-thread_process.c b/level_3/controller/c/thread/private-thread_process.c index 2bf7204..a172386 100644 --- a/level_3/controller/c/thread/private-thread_process.c +++ b/level_3/controller/c/thread/private-thread_process.c @@ -149,7 +149,7 @@ extern "C" { do { if (!process->id_thread) break; - f_thread_signal(process->id_thread, global.thread->signal ? global.thread->signal : F_signal_termination); + f_thread_signal_write(process->id_thread, global.thread->signal ? global.thread->signal : F_signal_termination); controller_time(0, controller_thread_exit_process_cancel_wait_d, &time);