Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New] Write a signal handler for handling list of signals to the process #30

Open
harsath opened this issue Jun 7, 2021 · 0 comments
Open
Assignees
Labels
New Extra attention is needed

Comments

@harsath
Copy link
Owner

harsath commented Jun 7, 2021

When a networking service needs a graceful config file restart or graceful shutdown of the worker threads or graceful shutdown, we have a specification for the list of signals and how the master process handles those signals by running specific code in the event of the specific signals.

It's better to have some abstraction to handle the code/helper subroutine execution service. The service class takes the list of signals and their callbacks to execute in the event.

It's also good to make the callback with a signature of void fn(Callable). In which we just invoke the callback. We assume that invoked callback doesn't take any arguments and also doesn't return some values which the user might be interested in. If they need to pass a piece of state information, they must have a class with operator()() overload to get around that.

Finally, we have a single method which the user should invoke to activate the signal handler since we don't take all the signal callbacks on the constructor.

We've a void signal_handler::install_callback(signal_type, callable_type) to take the callabcks and a switch-case jump statements to install the callbacks.

switch(signal_type) {
    case signal_type_one:
        callback_one = callback_type;
        return 0;
    case signal_type_two:
        callback_two = callback_type;
        return 0;
    default:
        return -1;
@harsath harsath added the New Extra attention is needed label Jun 7, 2021
@harsath harsath self-assigned this Jun 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant