diff options
author | David Walter Seikel | 2012-02-25 01:36:02 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-02-25 01:36:02 +1000 |
commit | db634cda56ca8eca2ddab728d1a95dc9fbd36eba (patch) | |
tree | cfd3e4930c4edfa416cd2edacc858a51a6591c62 /LuaSL/src/LuaSL_threads.h | |
parent | Moved luaproc into LuaSL, merged it all into it's own file, and replaced the ... (diff) | |
download | SledjHamr-db634cda56ca8eca2ddab728d1a95dc9fbd36eba.zip SledjHamr-db634cda56ca8eca2ddab728d1a95dc9fbd36eba.tar.gz SledjHamr-db634cda56ca8eca2ddab728d1a95dc9fbd36eba.tar.bz2 SledjHamr-db634cda56ca8eca2ddab728d1a95dc9fbd36eba.tar.xz |
Remove a whole bunch of stuff we don't need from our luaproc fork, and rearrange what's left.
Diffstat (limited to '')
-rw-r--r-- | LuaSL/src/LuaSL_threads.h | 161 |
1 files changed, 13 insertions, 148 deletions
diff --git a/LuaSL/src/LuaSL_threads.h b/LuaSL/src/LuaSL_threads.h index b12a50d..9fc38ea 100644 --- a/LuaSL/src/LuaSL_threads.h +++ b/LuaSL/src/LuaSL_threads.h | |||
@@ -32,168 +32,33 @@ THE SOFTWARE. | |||
32 | #ifndef __LUASL_THREADS_H__ | 32 | #ifndef __LUASL_THREADS_H__ |
33 | #define __LUASL_THREADS_H__ | 33 | #define __LUASL_THREADS_H__ |
34 | 34 | ||
35 | //#include <Ecore.h> | 35 | /* scheduler function return constants */ |
36 | 36 | #define LUAPROC_SCHED_OK 0 | |
37 | 37 | #define LUAPROC_SCHED_SOCKET_ERROR -1 | |
38 | #define CHANNEL_MAX_NAME_LENGTH 255 | 38 | #define LUAPROC_SCHED_SETSOCKOPT_ERROR -2 |
39 | #define LUAPROC_SCHED_BIND_ERROR -3 | ||
40 | #define LUAPROC_SCHED_LISTEN_ERROR -4 | ||
41 | #define LUAPROC_SCHED_FORK_ERROR -5 | ||
42 | #define LUAPROC_SCHED_PTHREAD_ERROR -6 | ||
43 | #define LUAPROC_SCHED_INIT_ERROR -7 | ||
39 | 44 | ||
40 | #define CHANNEL_DESTROYED 0 | ||
41 | 45 | ||
42 | /* message channel pointer type */ | 46 | /* message channel pointer type */ |
43 | typedef struct stchannel *channel; | 47 | typedef struct stchannel *channel; |
44 | 48 | ||
45 | |||
46 | |||
47 | /* scheduler function return constants */ | ||
48 | #define LUAPROC_SCHED_OK 0 | ||
49 | #define LUAPROC_SCHED_SOCKET_ERROR -1 | ||
50 | #define LUAPROC_SCHED_SETSOCKOPT_ERROR -2 | ||
51 | #define LUAPROC_SCHED_BIND_ERROR -3 | ||
52 | #define LUAPROC_SCHED_LISTEN_ERROR -4 | ||
53 | #define LUAPROC_SCHED_FORK_ERROR -5 | ||
54 | #define LUAPROC_SCHED_PTHREAD_ERROR -6 | ||
55 | #define LUAPROC_SCHED_INIT_ERROR -7 | ||
56 | |||
57 | /* ready process queue insertion status */ | ||
58 | #define LUAPROC_SCHED_QUEUE_PROC_OK 0 | ||
59 | #define LUAPROC_SCHED_QUEUE_PROC_ERR -1 | ||
60 | |||
61 | /* scheduler listener service default hostname and port */ | ||
62 | #define LUAPROC_SCHED_DEFAULT_HOST "127.0.0.1" | ||
63 | #define LUAPROC_SCHED_DEFAULT_PORT 3133 | ||
64 | |||
65 | /* scheduler default number of worker threads */ | ||
66 | #define LUAPROC_SCHED_DEFAULT_WORKER_THREADS 1 | ||
67 | |||
68 | |||
69 | |||
70 | /* process is idle */ | ||
71 | #define LUAPROC_STAT_IDLE 0 | ||
72 | /* process is ready to run */ | ||
73 | #define LUAPROC_STAT_READY 1 | ||
74 | /* process is blocked on send */ | ||
75 | #define LUAPROC_STAT_BLOCKED_SEND 2 | ||
76 | /* process is blocked on receive */ | ||
77 | #define LUAPROC_STAT_BLOCKED_RECV 3 | ||
78 | /* process is finished */ | ||
79 | #define LUAPROC_STAT_FINISHED 4 | ||
80 | |||
81 | /* lua process pointer type */ | 49 | /* lua process pointer type */ |
82 | typedef struct stluaproc *luaproc; | 50 | typedef struct stluaproc *luaproc; |
83 | 51 | ||
84 | 52 | ||
85 | 53 | void luaprocInit(void); | |
86 | |||
87 | |||
88 | /* initialize channels */ | ||
89 | void channel_init( void ); | ||
90 | |||
91 | /* create new channel */ | ||
92 | channel channel_create( const char *cname ); | ||
93 | |||
94 | /* destroy a channel */ | ||
95 | int channel_destroy( channel chan, const char *chname ); | ||
96 | |||
97 | /* search for and return a channel with a given name */ | ||
98 | channel channel_search( const char *cname ); | ||
99 | |||
100 | /* return a channel's send queue */ | ||
101 | Eina_Clist *channel_get_sendq( channel chan ); | ||
102 | |||
103 | /* return a channel's receive queue */ | ||
104 | Eina_Clist *channel_get_recvq( channel chan ); | ||
105 | |||
106 | /* return a channel's mutex */ | ||
107 | pthread_mutex_t *channel_get_mutex( channel chan ); | ||
108 | |||
109 | /* return a channel's conditional variable */ | ||
110 | pthread_cond_t *channel_get_cond( channel chan ); | ||
111 | |||
112 | |||
113 | |||
114 | |||
115 | |||
116 | |||
117 | /* initialize local scheduler */ | ||
118 | int sched_init_local( int numworkers ); | ||
119 | |||
120 | /* initialize socket enabled scheduler */ | ||
121 | int sched_init_socket( int numworkers, const char *host, int port ); | ||
122 | |||
123 | /* exit scheduler */ | ||
124 | void sched_exit( void ); | ||
125 | |||
126 | /* move process to ready queue (ie, schedule process) */ | ||
127 | int sched_queue_proc( luaproc lp ); | ||
128 | |||
129 | /* join all worker threads and exit */ | ||
130 | void sched_join_workerthreads( void ); | ||
131 | |||
132 | /* increase active luaproc count */ | ||
133 | void sched_lpcount_inc( void ); | ||
134 | |||
135 | /* decrease active luaproc count */ | ||
136 | void sched_lpcount_dec( void ); | ||
137 | 54 | ||
138 | /* create a new worker pthread */ | 55 | /* create a new worker pthread */ |
139 | int sched_create_worker( void ); | 56 | int sched_create_worker( void ); |
140 | 57 | ||
141 | 58 | int newProc(const char *code, int file, void *data); | |
142 | |||
143 | |||
144 | |||
145 | |||
146 | void luaprocInit(void); | ||
147 | void luaprocRegister(lua_State *L); | ||
148 | int newProc(const char *code, int file, Ecore_Cb callback, void *data); | ||
149 | |||
150 | |||
151 | /* return a process' status */ | ||
152 | int luaproc_get_status( luaproc lp ); | ||
153 | |||
154 | /* set a process' status */ | ||
155 | void luaproc_set_status( luaproc lp, int status ); | ||
156 | |||
157 | /* return a process' state */ | ||
158 | lua_State *luaproc_get_state( luaproc lp ); | ||
159 | |||
160 | /* return the number of arguments expected by a given a process */ | ||
161 | int luaproc_get_args( luaproc lp ); | ||
162 | |||
163 | /* set the number of arguments expected by a given process */ | ||
164 | void luaproc_set_args( luaproc lp, int n ); | ||
165 | |||
166 | /* create luaproc (from scheduler) */ | ||
167 | luaproc luaproc_create_sched( char *code ); | ||
168 | |||
169 | /* register luaproc's functions in a lua_State */ | ||
170 | void luaproc_register_funcs( lua_State *L ); | ||
171 | |||
172 | /* allow registering of luaproc's functions in c main prog */ | ||
173 | void luaproc_register_lib( lua_State *L ); | ||
174 | |||
175 | /* queue a luaproc that tried to send a message */ | ||
176 | void luaproc_queue_sender( luaproc lp ); | ||
177 | |||
178 | const char *sendToChannel(const char *chname, const char *message, luaproc *dst, channel *chn); | 59 | const char *sendToChannel(const char *chname, const char *message, luaproc *dst, channel *chn); |
179 | 60 | ||
180 | /* queue a luaproc that tried to receive a message */ | 61 | /* join all worker threads and exit */ |
181 | void luaproc_queue_receiver( luaproc lp ); | 62 | void sched_join_workerthreads( void ); |
182 | |||
183 | /* unlock a channel's access */ | ||
184 | void luaproc_unlock_channel( channel chan ); | ||
185 | |||
186 | /* return a luaproc's channel */ | ||
187 | channel luaproc_get_channel( luaproc lp ); | ||
188 | |||
189 | /* return status (boolean) indicating if worker thread should be destroyed after luaproc execution */ | ||
190 | int luaproc_get_destroyworker( luaproc lp ); | ||
191 | |||
192 | /* return status (boolean) indicating if lua process should be recycled */ | ||
193 | luaproc luaproc_recycle_pop( void ); | ||
194 | |||
195 | /* add a lua process to the recycle list */ | ||
196 | int luaproc_recycle_push( luaproc lp ); | ||
197 | |||
198 | 63 | ||
199 | #endif | 64 | #endif |