The Pedigree Project 0.1
TerminationDeferral.h
1/*
2 * Copyright (c) 2026, Pedigree Developers
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted.
6 */
7
8#ifndef PEDIGREE_KERNEL_PROCESS_TERMINATIONDEFERRAL_H
9#define PEDIGREE_KERNEL_PROCESS_TERMINATIONDEFERRAL_H
10#include "pedigree/kernel/compiler.h"
11#include "pedigree/kernel/process/DeferredScope.h"
12
13#include <config.h>
14
15class Thread;
16
27class EXPORTED_PUBLIC TerminationDeferral {
28 public:
29 // Keep the fresh-record constructor visible to avoid a redundant automatic
30 // stack fill before initialise() writes every field and publishes it.
31 explicit ALWAYS_INLINE TerminationDeferral(bool active = true)
32 : m_pThread(nullptr), m_Record(DeferredScopeRecord::Uninitialised{}) {
33 initialise(active);
34 }
37
38 TerminationDeferral& operator=(TerminationDeferral&& other) noexcept;
39
40 private:
41 void initialise(bool active);
42
44 TerminationDeferral& operator=(const TerminationDeferral&) = delete;
45
46 Thread* m_pThread;
47 DeferredScopeRecord m_Record;
48};
49
50#endif