summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormoteus <mimir@newmail.ru>2013-12-30 18:45:06 +0400
committermoteus <mimir@newmail.ru>2013-12-30 18:45:06 +0400
commit07819f3f402709890194a19b0525df426a097e76 (patch)
treeb4c003738cfc506820d8bdd2c5137b81277626f5
parentcff52e9ad84dea2ded2ee66bb0aef3e92a0c9e88 (diff)
downloadlua-llthreads2-07819f3f402709890194a19b0525df426a097e76.tar.gz
lua-llthreads2-07819f3f402709890194a19b0525df426a097e76.tar.bz2
lua-llthreads2-07819f3f402709890194a19b0525df426a097e76.zip
Code refactoring.
-rw-r--r--src/llthread.c38
1 files changed, 14 insertions, 24 deletions
diff --git a/src/llthread.c b/src/llthread.c
index 4f20840..354cdee 100644
--- a/src/llthread.c
+++ b/src/llthread.c
@@ -16,6 +16,8 @@
16#include <errno.h> 16#include <errno.h>
17#include <lualib.h> 17#include <lualib.h>
18#include "l52util.h" 18#include "l52util.h"
19#include "traceback.inc"
20#include "copy.inc"
19 21
20/*export*/ 22/*export*/
21#ifdef _WIN32 23#ifdef _WIN32
@@ -58,30 +60,6 @@ typedef int join_timeout_t;
58typedef pthread_t os_thread_t; 60typedef pthread_t os_thread_t;
59#endif 61#endif
60 62
61LLTHREADS_EXPORT_API int luaopen_llthreads(lua_State *L);
62
63#define LLTHREAD_T_NAME "LLThread"
64static const char *LLTHREAD_T = LLTHREAD_T_NAME;
65static const char *LLTHREAD_LOGGER_HOLDER = LLTHREAD_T_NAME " logger holder";
66
67//{ traceback
68
69#include "traceback.inc"
70
71//}
72
73//{ copy values
74
75#include "copy.inc"
76
77//}
78
79static int fail(lua_State *L, const char *msg){
80 lua_pushnil(L);
81 lua_pushstring(L, msg);
82 return 2;
83}
84
85#define ERROR_LEN 1024 63#define ERROR_LEN 1024
86 64
87#define flags_t unsigned char 65#define flags_t unsigned char
@@ -102,6 +80,12 @@ static int fail(lua_State *L, const char *msg){
102#define ALLOC_STRUCT(S) (S*)calloc(1, sizeof(S)) 80#define ALLOC_STRUCT(S) (S*)calloc(1, sizeof(S))
103#define FREE_STRUCT(O) free(O) 81#define FREE_STRUCT(O) free(O)
104 82
83LLTHREADS_EXPORT_API int luaopen_llthreads(lua_State *L);
84
85#define LLTHREAD_T_NAME "LLThread"
86static const char *LLTHREAD_T = LLTHREAD_T_NAME;
87static const char *LLTHREAD_LOGGER_HOLDER = LLTHREAD_T_NAME " logger holder";
88
105typedef struct llthread_child_t { 89typedef struct llthread_child_t {
106 lua_State *L; 90 lua_State *L;
107 int status; 91 int status;
@@ -114,6 +98,12 @@ typedef struct llthread_t {
114 flags_t flags; 98 flags_t flags;
115} llthread_t; 99} llthread_t;
116 100
101static int fail(lua_State *L, const char *msg){
102 lua_pushnil(L);
103 lua_pushstring(L, msg);
104 return 2;
105}
106
117//{ logger interface 107//{ logger interface
118void llthread_log(lua_State *L, const char *hdr, const char *msg){ 108void llthread_log(lua_State *L, const char *hdr, const char *msg){
119 int top = lua_gettop(L); 109 int top = lua_gettop(L);