diff options
Diffstat (limited to '')
-rw-r--r-- | LuaSL/src/LuaSL_threads.h (renamed from libraries/luaproc/luaproc.h) | 115 |
1 files changed, 107 insertions, 8 deletions
diff --git a/libraries/luaproc/luaproc.h b/LuaSL/src/LuaSL_threads.h index 1286107..b12a50d 100644 --- a/libraries/luaproc/luaproc.h +++ b/LuaSL/src/LuaSL_threads.h | |||
@@ -1,4 +1,8 @@ | |||
1 | /*************************************************** | 1 | /* This code is heavily based on luaproc. |
2 | * | ||
3 | * The luaproc copyright notice and license is - | ||
4 | |||
5 | *************************************************** | ||
2 | 6 | ||
3 | Copyright 2008 Alexandre Skyrme, Noemi Rodriguez, Roberto Ierusalimschy | 7 | Copyright 2008 Alexandre Skyrme, Noemi Rodriguez, Roberto Ierusalimschy |
4 | 8 | ||
@@ -20,16 +24,48 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |||
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
21 | THE SOFTWARE. | 25 | THE SOFTWARE. |
22 | 26 | ||
23 | ***************************************************** | 27 | **************************************************** |
28 | * | ||
29 | * Additions and changes Copyright 2012 by David Seikel, using the above license. | ||
30 | */ | ||
31 | |||
32 | #ifndef __LUASL_THREADS_H__ | ||
33 | #define __LUASL_THREADS_H__ | ||
34 | |||
35 | //#include <Ecore.h> | ||
36 | |||
37 | |||
38 | #define CHANNEL_MAX_NAME_LENGTH 255 | ||
39 | |||
40 | #define CHANNEL_DESTROYED 0 | ||
41 | |||
42 | /* message channel pointer type */ | ||
43 | typedef struct stchannel *channel; | ||
44 | |||
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 | ||
24 | 60 | ||
25 | [luaproc.h] | 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 | ||
26 | 67 | ||
27 | ****************************************************/ | ||
28 | #ifndef _LUAPROC_H_ | ||
29 | #define _LUAPROC_H_ | ||
30 | 68 | ||
31 | #include "channel.h" | ||
32 | #include <Ecore.h> | ||
33 | 69 | ||
34 | /* process is idle */ | 70 | /* process is idle */ |
35 | #define LUAPROC_STAT_IDLE 0 | 71 | #define LUAPROC_STAT_IDLE 0 |
@@ -45,6 +81,68 @@ THE SOFTWARE. | |||
45 | /* lua process pointer type */ | 81 | /* lua process pointer type */ |
46 | typedef struct stluaproc *luaproc; | 82 | typedef struct stluaproc *luaproc; |
47 | 83 | ||
84 | |||
85 | |||
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 | |||
138 | /* create a new worker pthread */ | ||
139 | int sched_create_worker( void ); | ||
140 | |||
141 | |||
142 | |||
143 | |||
144 | |||
145 | |||
48 | void luaprocInit(void); | 146 | void luaprocInit(void); |
49 | void luaprocRegister(lua_State *L); | 147 | void luaprocRegister(lua_State *L); |
50 | int newProc(const char *code, int file, Ecore_Cb callback, void *data); | 148 | int newProc(const char *code, int file, Ecore_Cb callback, void *data); |
@@ -97,4 +195,5 @@ luaproc luaproc_recycle_pop( void ); | |||
97 | /* add a lua process to the recycle list */ | 195 | /* add a lua process to the recycle list */ |
98 | int luaproc_recycle_push( luaproc lp ); | 196 | int luaproc_recycle_push( luaproc lp ); |
99 | 197 | ||
198 | |||
100 | #endif | 199 | #endif |