aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/llthread.c25
-rw-r--r--src/lua/llthreads2/ex.lua18
2 files changed, 41 insertions, 2 deletions
diff --git a/src/llthread.c b/src/llthread.c
index 0ffa727..33eab4f 100644
--- a/src/llthread.c
+++ b/src/llthread.c
@@ -4,8 +4,8 @@
4 4
5#define LLTHREAD_VERSION_MAJOR 0 5#define LLTHREAD_VERSION_MAJOR 0
6#define LLTHREAD_VERSION_MINOR 1 6#define LLTHREAD_VERSION_MINOR 1
7#define LLTHREAD_VERSION_PATCH 0 7#define LLTHREAD_VERSION_PATCH 2
8#define LLTHREAD_VERSION_COMMENT "" 8#define LLTHREAD_VERSION_COMMENT "dev"
9 9
10#ifndef USE_PTHREAD 10#ifndef USE_PTHREAD
11# include <windows.h> 11# include <windows.h>
@@ -660,6 +660,24 @@ static int l_llthread_alive(lua_State *L) {
660 660
661} 661}
662 662
663static int l_llthread_started(lua_State *L) {
664 llthread_t *this = l_llthread_at(L, 1);
665 lua_pushboolean(L, IS(this, STARTED)?1:0);
666 return 1;
667}
668
669static int l_llthread_detached(lua_State *L) {
670 llthread_t *this = l_llthread_at(L, 1);
671 lua_pushboolean(L, IS(this, DETACHED)?1:0);
672 return 1;
673}
674
675static int l_llthread_joinable(lua_State *L) {
676 llthread_t *this = l_llthread_at(L, 1);
677 lua_pushboolean(L, IS(this, JOINABLE)?1:0);
678 return 1;
679}
680
663static int l_llthread_new(lua_State *L) { 681static int l_llthread_new(lua_State *L) {
664 size_t lua_code_len; const char *lua_code = luaL_checklstring(L, 1, &lua_code_len); 682 size_t lua_code_len; const char *lua_code = luaL_checklstring(L, 1, &lua_code_len);
665 llthread_t **this = lutil_newudatap(L, llthread_t*, LLTHREAD_TAG); 683 llthread_t **this = lutil_newudatap(L, llthread_t*, LLTHREAD_TAG);
@@ -674,6 +692,9 @@ static const struct luaL_Reg l_llthread_meth[] = {
674 {"start", l_llthread_start }, 692 {"start", l_llthread_start },
675 {"join", l_llthread_join }, 693 {"join", l_llthread_join },
676 {"alive", l_llthread_alive }, 694 {"alive", l_llthread_alive },
695 {"started", l_llthread_started },
696 {"detached", l_llthread_detached },
697 {"joinable", l_llthread_joinable },
677 {"__gc", l_llthread_delete }, 698 {"__gc", l_llthread_delete },
678 699
679 {NULL, NULL} 700 {NULL, NULL}
diff --git a/src/lua/llthreads2/ex.lua b/src/lua/llthreads2/ex.lua
index 06af3a5..77f8d5e 100644
--- a/src/lua/llthreads2/ex.lua
+++ b/src/lua/llthreads2/ex.lua
@@ -123,6 +123,24 @@ function thread_mt:alive()
123 return self.thread:alive() 123 return self.thread:alive()
124end 124end
125 125
126--- Check if thread was started.
127--
128function thread_mt:started()
129 return self.thread:started()
130end
131
132--- Check if thread is detached.
133-- This function returns valid value only for started thread.
134function thread_mt:detached()
135 return self.thread:detached()
136end
137
138--- Check if thread is joinable.
139-- This function returns valid value only for started thread.
140function thread_mt:joinable()
141 return self.thread:joinable()
142end
143
126end 144end
127------------------------------------------------------------------------------- 145-------------------------------------------------------------------------------
128 146