aboutsummaryrefslogtreecommitdiff
path: root/lib/thread.h
blob: e39205200f47f6a1c9e52788255af5a472b7bd9d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* Copyright (c) 2020 Johannes Stoelp */

#pragma once

namespace nMatcha {
    struct Executor;

    struct Thread {
        Thread(const Thread&) = delete;
        Thread& operator=(const Thread&) = delete;
        Thread();
        virtual ~Thread() {}

        virtual void threadFn() = 0;

      protected:
        void yield();

      private:
        static void entry(void* obj);
        void* mStackPtr;

        friend struct Executor;
        const Executor* mExecutor;
    };
}  // namespace nMatcha