Serenity Operating System
1/*
2 * Copyright (c) 2020, Tom <tomut@yahoo.com>
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7#pragma once
8
9#include <AK/BitCast.h>
10#include <AK/Function.h>
11
12namespace Kernel {
13
14struct DeferredCallEntry {
15 using HandlerFunction = Function<void()>;
16
17 DeferredCallEntry* next;
18 alignas(HandlerFunction) u8 handler_storage[sizeof(HandlerFunction)];
19 bool was_allocated;
20
21 HandlerFunction& handler_value()
22 {
23 return *bit_cast<HandlerFunction*>(&handler_storage);
24 }
25
26 void invoke_handler()
27 {
28 handler_value()();
29 }
30};
31
32}