getting close to mlp running a limited program
[IRC.git] / Robust / src / Runtime / mlp_runtime.h
1 #ifndef __MLP_RUNTIME__
2 #define __MLP_RUNTIME__
3
4
5 #include <pthread.h>
6 #include "Queue.h"
7 #include "psemaphore.h"
8
9
10 // forward delcarations
11 struct SESErecord_t;
12 struct invokeSESEargs_t;
13
14
15 typedef struct SESEvar_t {
16   // the value when it is known will be placed
17   // in this location, which can be accessed
18   // as a variety of types
19   union {
20     char      sesetype_byte;
21     int       sesetype_boolean;
22     short     sesetype_short;
23     int       sesetype_int;
24     long long sesetype_long;
25     short     sesetype_char;
26     float     sesetype_float;
27     double    sesetype_double;
28     void*     sesetype_object;
29   };  
30 } SESEvar;
31
32
33 typedef struct SESErecord_t {  
34   // the identifier for the class of sese's that
35   // are instances of one particular static code block
36   int classID;
37
38   // for state of vars after issue
39   void* namespace;
40   
41   // when this sese is ready to be invoked,
42   // allocate and fill in this structure, and
43   // the primitives will be passed out of the
44   // above var array at the call site
45   void* paramStruct;
46
47   /*
48   // for signaling transition from issue 
49   // to execute
50   pthread_cond_t*  startCondVar;
51   pthread_mutex_t* startCondVarLock;
52   int startedExecuting;
53   */
54
55   // this will not be generally sufficient, but
56   // use a semaphore to let a child resume this
57   // parent when stall dependency is satisfied
58   psemaphore stallSem;
59
60   // use a list of SESErecords and a lock to let
61   // consumers tell this SESE who wants values
62   // forwarded to it
63   pthread_mutex_t forwardListLock;
64   struct Queue*   forwardList;
65   int doneExecuting;
66
67 } SESErecord;
68
69
70 typedef struct invokeSESEargs_t {
71   int classID;
72   SESErecord* invokee;
73   SESErecord* parent;
74 } invokeSESEargs;
75
76
77 // simple mechanical allocation and deallocation
78 // of SESE records
79 SESErecord* mlpCreateSESErecord( int   classID,
80                                  void* namespace,
81                                  void* paramStruct
82                                  );
83
84 void mlpDestroySESErecord( SESErecord* sese );
85
86
87 // main library functions
88 void mlpInit();
89
90 //SESErecord* mlpGetCurrent();
91 SESErecord* mlpSchedule();
92
93 void mlpIssue     ( SESErecord* sese );
94 void mlpStall     ( SESErecord* sese );
95 void mlpNotifyExit( SESErecord* sese );
96
97
98 extern SESErecord* rootsese;
99
100
101 #endif /* __MLP_RUNTIME__ */