My Project
NeuronFileState.h
1 #pragma once
2 
3 #include "NPLMessageQueue.h"
4 #include "NPLCommon.h"
5 
6 namespace NPL
7 {
8  using namespace std;
9  class CNPLRuntimeState;
10 
15  {
16  public:
17  CNeuronFileState(const std::string& filename);
18 
21  bool IsProcessing() const;
22  void SetProcessing(bool val);
23 
25  bool PushMessage(NPLMessage_ptr& msg);
26 
30  bool PopMessage(NPLMessage_ptr& msg);
31 
33  bool GetMessage(NPLMessage_ptr& msg);
34 
36  bool IsEmpty();
37 
39  void ClearMessage();
40 
41  /* check if there is clear state and unset it.
42  * return true if there is a clear state */
43  bool PopClearState();
44 
48  void Tick(int nFrameMoveId);
49 
53  int GetTick(int nFrameMoveId);
54 
58  int32 GetMaxQueueSize() const;
59  void SetMaxQueueSize(int32 val);
60 
62  const std::string& GetFilename() const { return m_filename; }
63 
65  bool IsPreemptive();
67  int32 GetPreemptiveInstructionCount() const;
68  void SetPreemptiveInstructionCount(int32 val);
69 
70  protected:
71  /* clear all messages and shrink message queue (releasing memory).*/
72  void ClearMessageImp();
73  friend class CNPLRuntimeState;
74  protected:
93  std::deque<NPLMessage_ptr> m_queue;
95  std::string m_filename;
96  };
97 }
int32 m_nMaxQueueSize
max number of messages in the pending message queue.
Definition: NeuronFileState.h:91
DWORD m_nActionState
action state
Definition: NeuronFileState.h:84
define this to enable debugging of NPL code in visual studio
Definition: INPL.h:9
std::deque< NPLMessage_ptr > m_queue
the pending message queue
Definition: NeuronFileState.h:93
int32 m_nTotalActivations
total number of activations since program starts.
Definition: NeuronFileState.h:80
A runtime state contains the scripting runtime stack and can be run in a single thread.
Definition: NPLRuntimeState.h:35
std::string m_filename
neuron file name
Definition: NeuronFileState.h:95
int32 m_nFrameMoveId
different for each tick
Definition: NeuronFileState.h:78
Check to see if it is a tick.
Definition: Tick.h:5
bool m_isProcessing
whether the message is still being processed in the activation function.
Definition: NeuronFileState.h:87
int32 m_nPreemptiveInstructionCount
if not 0, we will use coroutine and debug hook to simulate preemptive scheduling in user mode...
Definition: NeuronFileState.h:82
int32 m_nActivationThisTick
total number of activation calls in this/last tick.
Definition: NeuronFileState.h:76
each neuron file that is activated will have a CNeuronFileState structure kept.
Definition: NeuronFileState.h:14
const std::string & GetFilename() const
neuron file name
Definition: NeuronFileState.h:62