blob: f4cbf138d613194f4ad5f1895812f4e8cc460569 (plain
* Copyright © 2018 Intel Corporation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
#define ALLOW_DEPRECATED_API 1
// make it possible to ONLY include api.hpp during the transition
// any client can interact with the main asio context
// any client can interact with the main sdbus
* @brief post some work to the async exection queue
* The IPMI daemon runs an async exection queue; this allows any function to
* pass in work to be executed in that context
* @tparam WorkFn - a function of type void(void)
* @param work - the callback function to be executed
template <typename WorkFn>
static inline void post_work(WorkFn work)
enum class SignalResponse : int
* @brief add a signal handler
* This registers a handler to be called asynchronously via the execution
* queue when the specified signal is received.
* Priority allows a signal handler to specify what order in the handler
* chain it gets called. Lower priority numbers will cause the handler to
* be executed later in the chain, while the highest priority numbers will cause
* the handler to be executed first.
* In order to facilitate a chain of handlers, each handler in the chain will be
* able to return breakExecution or continueExecution. Returning breakExecution
* will break the chain and no further handlers will execute for that signal.
* Returning continueExecution will allow lower-priority handlers to execute.
* By default, the main asio execution loop will register a low priority
* (prioOpenBmcBase) handler for SIGINT and SIGTERM to cause the process to stop
* on either of those signals. To prevent one of those signals from causing the
* process to stop, simply register a higher priority handler that returns
* @param int - priority of handler
* @param int - signal number to wait for
* @param handler - the callback function to be executed
void registerSignalHandler(int priority, int signalNumber,
const std::function<SignalResponse(int)>& handler);