//FTTThread - [2020-04-13 11:57:47]
#ifndef _FTTTHREAD_H_
#define _FTTTHREAD_H_

#include "common.h"
#include <pthread.h>

/*
0026CF24 FTTThread::FTTThread(int (*)(void *),void *,int,int,char const*)
0026CF8E FTTThread::~FTTThread()
0026CF7C FTTThread::ThreadWrapper(void *)
0026CFA0 FTTThread::GetCurrent()
0026CFA6 FTTThread::GetCurrentCPU()
0026CFAA FTTThread::SetCPU(int)
0026CFAC FTTThread::ExitThread(int)
0026CFB2 FTTThread::GetExitCode(int *)
0026CFDA FTTThread::SleepThread(int)
0026CFEE FTTThread::YieldThread()
0026CFF2 FTTThread::SuspendThread()
0026CFF6 FTTThread::ResumeThread()
0026D2A8 FTTThread_CreateMutex(bool,char const*)
0026D4CC FTTThread_CreateSemaphore(int,int,char *)
0026CFFC FTTThread_CreateThread(int (*)(void *),void *,int,int,char const*)
0026D338 FTTThread_DeleteMutex(int)
0026D4DC FTTThread_DeleteSemaphore(int)
0026D190 FTTThread_DeleteThread(int)
0026D1D0 FTTThread_ExitThread(int)
0026D188 FTTThread_GetCurrentCPU()
0026D154 FTTThread_GetCurrentThread()
0026D1D8 FTTThread_GetExitCode(int,int *)
0026D4E4 FTTThread_GetSemaCount(int)
0026D374 FTTThread_LockMutex(int)
0026D244 FTTThread_ResumeThread(int)
0026D18C FTTThread_SetCPU(int,int)
0026D4E2 FTTThread_SignalSema(int,int)
0026D228 FTTThread_Sleep(int)
0026D240 FTTThread_SuspendThread(int)
0026D390 FTTThread_TryLockMutex(int)
0026D3B0 FTTThread_UnlockMutex(int)
0026D4DE FTTThread_WaitSema(int,int)
0026D23C FTTThread_Yield()
*/

//typedef int (*fp_thread_func)(void *a1);
typedef int (*ThreadFun)(void *pobj);

enum EFTTThreadPriority {
  EFTTThreadPriority_0,
  EFTTThreadPriority_1,
  EFTTThreadPriority_2,
  EFTTThreadPriority_3,
  EFTTThreadPriority_4,
  EFTTThreadPriority_5,
  EFTTThreadPriority_6,
  EFTTThreadPriority_7,
  EFTTThreadPriority_8,
  EFTTThreadPriority_9,
  EFTTThreadPriority_10,
  EFTTThreadPriority_11,
  EFTTThreadPriority_12
};
//-------------------------------------------------------------------------------------------------
class FTTThread {
public:
  FTTThread(ThreadFun func_callback,
            void *func_arg,
            int a3,
            int dStackSize,
            const char *pName);          //0026CF24
  ~FTTThread();                          //0026CF8E
  int GetExitCode(int *a2);              //0026CFB2
  static int ThreadWrapper(void *a1);    //0026CF7C
  static void ExitThread(void *retval);  //0026CFAC
  static int GetCurrent();               //0026CFA0
  static int GetCurrentCPU();            //0026CFA6
  static int ResumeThread();             //0026CFF6
  static void SetCPU(int);               //0026CFAA
  static int SleepThread(int a2);        //0026CFDA
  static int SuspendThread();            //0026CFF2
  static int YieldThread();              //0026CFEE

  pthread_t field_0;
  ThreadFun func_4;
  void *field_8;
  bool field_C;
  int field_10;
  char field_14[32];
};
//-------------------------------------------------------------------------------------------------
int FTTThread_CreateMutex(bool a1, char const *a2);  //0026D2A8
int FTTThread_CreateSemaphore();                     //0026D4CC
pthread_t FTTThread_CreateThread(ThreadFun pFunc,
                                 void *pArg,
                                 int ePriority,
                                 int stacksize,
                                 char const *name);    //0026CFFC
void FTTThread_DeleteMutex(int index);                 //0026D338
void FTTThread_DeleteSemaphore();                      //0026D4DC
void FTTThread_DeleteThread(int index);                //0026D190
void FTTThread_ExitThread(void *a1);                   //0026D1D0
int FTTThread_GetCurrentCPU();                         //0026D188
int FTTThread_GetCurrentThread();                      //0026D154
int FTTThread_GetExitCode(int index, int *pExitCode);  //0026D1D8
int FTTThread_GetSemaCount();                          //0026D4E4
int FTTThread_LockMutex(int index);                    //0026D374
int FTTThread_ResumeThread(int index);                 //0026D244
void FTTThread_SetCPU();                               //0026D18C
void FTTThread_SignalSema();                           //0026D4E2
int FTTThread_Sleep(int a1);                           //0026D228
int FTTThread_SuspendThread(int a1);                   //0026D240
bool FTTThread_TryLockMutex(int a1);                   //0026D390
int FTTThread_UnlockMutex(int index);                  //0026D3B0
int FTTThread_WaitSema();                              //0026D4DE
int FTTThread_Yield();                                 //0026D23C
//-------------------------------------------------------------------------------------------------

#endif  //_FTTTHREAD_H_