aboutsummaryrefslogblamecommitdiff
path: root/lib/thread.h
blob: d98373406db782f5dc8a0539f6a88df6169df610 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15














                                                  

                                                     





                                     
                       




                                  
/* 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;

        bool isFinished() const { return mFinished; }

      protected:
        void yield();

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

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