summaryrefslogtreecommitdiff
path: root/src/common/thread.c
diff options
context:
space:
mode:
authorhemagx <hemagx2@gmail.com>2016-03-01 07:48:59 +0200
committerHaru <haru@dotalux.com>2016-07-12 20:58:41 +0200
commit257b9e11ab6cf503d0b9582eb855ea0b50ec8877 (patch)
tree9110aa9f8647ef7a13702d05fc06f11ea0ca8830 /src/common/thread.c
parentd0355d1df812f75e22f2d0538a1850d4e1274078 (diff)
downloadhercules-257b9e11ab6cf503d0b9582eb855ea0b50ec8877.tar.gz
hercules-257b9e11ab6cf503d0b9582eb855ea0b50ec8877.tar.bz2
hercules-257b9e11ab6cf503d0b9582eb855ea0b50ec8877.tar.xz
hercules-257b9e11ab6cf503d0b9582eb855ea0b50ec8877.zip
Interface thread.c
Diffstat (limited to 'src/common/thread.c')
-rw-r--r--src/common/thread.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/common/thread.c b/src/common/thread.c
index b724344e6..7bcffaf86 100644
--- a/src/common/thread.c
+++ b/src/common/thread.c
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2015 Hercules Dev Team
+ * Copyright (C) 2012-2016 Hercules Dev Team
* Copyright (C) rAthena Project (www.rathena.org)
*
* Hercules is free software: you can redistribute it and/or modify
@@ -68,6 +68,9 @@ struct rAthread {
__thread int g_rathread_ID = -1;
#endif
+struct thread_interface thread_s;
+struct thread_interface *thread;
+
///
/// Subystem Code
///
@@ -100,7 +103,7 @@ void rathread_final(void) {
for(i = 1; i < RA_THREADS_MAX; i++){
if(l_threads[i].proc != NULL){
ShowWarning("rAthread_final: unterminated Thread (tid %u entryPoint %p) - forcing to terminate (kill)\n", i, l_threads[i].proc);
- rathread_destroy(&l_threads[i]);
+ thread->destroy(&l_threads[i]);
}
}
@@ -159,7 +162,7 @@ static void *raThreadMainRedirector( void *p ){
/// API Level
///
rAthread *rathread_create(rAthreadProc entryPoint, void *param) {
- return rathread_createEx( entryPoint, param, (1<<23) /*8MB*/, RAT_PRIO_NORMAL );
+ return thread->createEx(entryPoint, param, (1<<23) /*8MB*/, RAT_PRIO_NORMAL);
}//end: rathread_create()
rAthread *rathread_createEx(rAthreadProc entryPoint, void *param, size_t szStack, RATHREAD_PRIO prio) {
@@ -205,7 +208,7 @@ rAthread *rathread_createEx(rAthreadProc entryPoint, void *param, size_t szStack
pthread_attr_destroy(&attr);
#endif
- rathread_prio_set( handle, prio );
+ thread->prio_set( handle, prio );
return handle;
}//end: rathread_createEx
@@ -301,3 +304,19 @@ void rathread_yield(void) {
sched_yield();
#endif
}//end: rathread_yield()
+
+void thread_defaults(void)
+{
+ thread = &thread_s;
+ thread->create = rathread_create;
+ thread->createEx = rathread_createEx;
+ thread->destroy = rathread_destroy;
+ thread->self = rathread_self;
+ thread->get_tid = rathread_get_tid;
+ thread->wait = rathread_wait;
+ thread->prio_set = rathread_prio_set;
+ thread->prio_get = rathread_prio_get;
+ thread->yield = rathread_yield;
+ thread->init = rathread_init;
+ thread->final = rathread_final;
+}