aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorame <[email protected]>2025-10-28 17:38:31 -0500
committerame <[email protected]>2025-10-28 17:38:31 -0500
commit77a371ec23b0ecf13b002df2d28461d88b5785cc (patch)
treebd7da703eaa58a96bfc387197ac7a7ea44d4ef25 /src
parent0a7692a87f0bf16f59e451df52c91aad5affce38 (diff)
remove tlock, tunlock
Diffstat (limited to 'src')
-rw-r--r--src/thread.c65
-rw-r--r--src/thread.h4
2 files changed, 0 insertions, 69 deletions
diff --git a/src/thread.c b/src/thread.c
index 7d48bda..2a2de39 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -23,71 +23,6 @@ struct thread_info {
#include "io.h"
-//give the current thread priority to locking thread_lock_lock (fixes race conds)
-pthread_mutex_t thread_priority_lock = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;
-pthread_mutex_t thread_lock_lock = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;
-larray_t* thread_locks = NULL;
-
-void lib_thread_clean(){
- if(thread_locks == NULL) return;
-
- for(int i = 0; i != thread_locks->size; i++){
- if(thread_locks->arr[i].used){
- //pthread_mutex_destroy(thread_locks->arr[i].value);
- free(thread_locks->arr[i].value);
- }
- }
-
- larray_clear(thread_locks);
-}
-int l_tlock(lua_State* L){
- int idx = luaL_checkinteger(L, 1);
-
- pthread_mutex_lock(&thread_lock_lock);
- //pthread_mutex_lock(&thread_priority_lock);
- //pthread_mutex_unlock(&thread_priority_lock);
- pthread_mutex_t mutex;
- if(thread_locks == NULL) thread_locks = larray_init();
- int i = 0;
- if((i = larray_geti(thread_locks, idx)) == -1){
- pthread_mutex_init(&mutex, NULL);
- pthread_mutex_lock(&mutex);
- pthread_mutex_t* mp = malloc(sizeof * mp);
- *mp = mutex;
- larray_set(&thread_locks, idx, (void*)mp);
- } else {
- pthread_mutex_t *m = (pthread_mutex_t*)thread_locks->arr[i].value;
- pthread_mutex_lock(&thread_priority_lock);
-
- pthread_mutex_unlock(&thread_lock_lock);
- pthread_mutex_lock(m);
- pthread_mutex_lock(&thread_lock_lock);
-
- pthread_mutex_unlock(&thread_priority_lock);
- thread_locks->arr[i].value = (void*)m;
-
- }
-
- pthread_mutex_unlock(&thread_lock_lock);
- return 0;
-}
-
-int l_tunlock(lua_State* L){
- int idx = luaL_checkinteger(L, 1);
-
- pthread_mutex_lock(&thread_lock_lock);
- int i = 0;
- if(thread_locks != NULL && (i = larray_geti(thread_locks, idx)) != -1){
- pthread_mutex_t *m = (pthread_mutex_t*)thread_locks->arr[i].value;
-
- pthread_mutex_unlock(m);
- thread_locks->arr[i].value = (void*)m;
- }
-
- pthread_mutex_unlock(&thread_lock_lock);
- return 0;
-}
-
int _mutex_lock(lua_State* L){
lua_pushstring(L, "_");
lua_gettable(L, 1);
diff --git a/src/thread.h b/src/thread.h
index 4fa0e04..f0435eb 100644
--- a/src/thread.h
+++ b/src/thread.h
@@ -6,8 +6,6 @@
#endif
int l_async(lua_State*);
-int l_tlock(lua_State*);
-int l_tunlock(lua_State*);
int l_buffer(lua_State*);
int l_testcopy(lua_State*);
int l_mutex(lua_State*);
@@ -18,8 +16,6 @@ void lib_thread_clean();
static const luaL_Reg thread_function_list [] = {
{"async",l_async},
- {"lock",l_tlock},
- {"unlock",l_tunlock},
{"buffer",l_buffer},
{"testcopy",l_testcopy},
{"mutex", l_mutex},