diff options
author | moteus <mimir@newmail.ru> | 2013-12-30 18:45:06 +0400 |
---|---|---|
committer | moteus <mimir@newmail.ru> | 2013-12-30 18:45:06 +0400 |
commit | 07819f3f402709890194a19b0525df426a097e76 (patch) | |
tree | b4c003738cfc506820d8bdd2c5137b81277626f5 | |
parent | cff52e9ad84dea2ded2ee66bb0aef3e92a0c9e88 (diff) | |
download | lua-llthreads2-07819f3f402709890194a19b0525df426a097e76.tar.gz lua-llthreads2-07819f3f402709890194a19b0525df426a097e76.tar.bz2 lua-llthreads2-07819f3f402709890194a19b0525df426a097e76.zip |
Code refactoring.
-rw-r--r-- | src/llthread.c | 38 |
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; | |||
58 | typedef pthread_t os_thread_t; | 60 | typedef pthread_t os_thread_t; |
59 | #endif | 61 | #endif |
60 | 62 | ||
61 | LLTHREADS_EXPORT_API int luaopen_llthreads(lua_State *L); | ||
62 | |||
63 | #define LLTHREAD_T_NAME "LLThread" | ||
64 | static const char *LLTHREAD_T = LLTHREAD_T_NAME; | ||
65 | static 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 | |||
79 | static 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 | ||
83 | LLTHREADS_EXPORT_API int luaopen_llthreads(lua_State *L); | ||
84 | |||
85 | #define LLTHREAD_T_NAME "LLThread" | ||
86 | static const char *LLTHREAD_T = LLTHREAD_T_NAME; | ||
87 | static const char *LLTHREAD_LOGGER_HOLDER = LLTHREAD_T_NAME " logger holder"; | ||
88 | |||
105 | typedef struct llthread_child_t { | 89 | typedef 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 | ||
101 | static 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 |
118 | void llthread_log(lua_State *L, const char *hdr, const char *msg){ | 108 | void llthread_log(lua_State *L, const char *hdr, const char *msg){ |
119 | int top = lua_gettop(L); | 109 | int top = lua_gettop(L); |