| 
    Cavestory Mod API
    
   | 
 
Easy multi-threading for modes. More...
#include <CSMAPI_BaseModeInstance.h>
Public Types | |
| enum | ThreadState {  THREAD_NOT_RUNNING = 0 , THREAD_STARTING = 1 , THREAD_RUNNING = 2 , THREAD_STOPPING = 3 , THREAD_DELETABLE = 4 }  | 
| Thread states.  More... | |
| typedef void(* | ModeCallback_OnThreadComplete) (BaseModeInstance *pMode, ModeThreadInstance *pThread, void *pUserData) | 
| Callback function for when a thread completes.  | |
| typedef void(* | ModeCallback_OnThreadLoop) (BaseModeInstance *pMode, ModeThreadInstance *pThread, void *pUserData) | 
| Callback function for when a thread completes.  | |
Public Member Functions | |
| ModeThreadInstance () | |
| Main constructor.  | |
| ~ModeThreadInstance () | |
| Deconstructor.  | |
| bool | TryLockUnique () | 
| Try to lock a critical part of code.  More... | |
| void | LockUnique () | 
| Lock a critical part of code.  | |
| void | UnlockUnique () | 
| Unlock a critical part of code.  | |
| bool | Start () | 
| Start the thread.  | |
| void | End (int iResult=0) | 
| End the thread.  | |
| void | WaitToFinish () | 
| Wait for the thread to finish.  | |
| void | Detach () | 
| Detach this thread.  | |
| int | GetResult () | 
| Get the return result.  | |
Static Public Member Functions | |
| static bool | TryLock () | 
| Try to lock a critical part of code.  More... | |
| static void | Lock () | 
| Lock a critical part of code.  | |
| static void | Unlock () | 
| Unlock a critical part of code.  | |
Protected Member Functions | |
| bool | InitThread (BaseModeInstance *pOwner, ModeCallback_OnThreadLoop pOnLoopFunc, ModeCallback_OnThreadComplete pOnCompleteFunc, void *pUserData=NULL) | 
| Initialize this thread instance.  More... | |
| void | __Complete_And_Send_Result__ () | 
| Complete this mode.  More... | |
Protected Attributes | |
| char | m_ThreadName [128] | 
| The thread name.  | |
| ModeThreadId | m_ThreadId | 
| This thread's local ID.  | |
| ModeCallback_OnThreadComplete | m_OnComplete | 
| Called when the asynchronous operation ends, by any means.  | |
| ModeCallback_OnThreadComplete | m_OnLoop | 
| Called every frame.  | |
| BaseModeInstance * | m_Owner | 
| The owner of this thread.  | |
| void * | m_Thread | 
| The thread for this mode.  | |
| void * | m_Mutex | 
| This thread's unique mutex.  | |
| ThreadState | m_State | 
| The state of this thread.  | |
| bool | m_Running | 
| This is controlled by the async function.  | |
| int | m_Result | 
| The result from the async operation.  | |
| void * | m_UserData | 
| Function callback userdata.  | |
Friends | |
| class | BaseModeInstance | 
| int | ModeThreadInstance_AsyncFunc (void *ptr) | 
Easy multi-threading for modes.
      
  | 
  protected | 
Complete this mode.
Do not call this.
      
  | 
  protected | 
Initialize this thread instance.
| pOwner | The owner of this thread. | 
| pOnLoopFunc | The 'OnLoop' callback function. | 
| pOnCompleteFunc | The 'OnComplete' callback function. | 
| pUserData | The user data for the callback functions. | 
      
  | 
  static | 
Try to lock a critical part of code.
| bool ModeThreadInstance::TryLockUnique | ( | ) | 
Try to lock a critical part of code.