The world's most popular open source database
#include <ndb_global.h>Include dependency graph for NdbThread.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Typedefs | |
| typedef enum NDB_THREAD_PRIO_ENUM | NDB_THREAD_PRIO |
| typedef void *( | NDB_THREAD_FUNC )(void *) |
| typedef void * | NDB_THREAD_ARG |
| typedef size_t | NDB_THREAD_STACKSIZE |
Enumerations | |
| enum | NDB_THREAD_PRIO_ENUM { NDB_THREAD_PRIO_HIGHEST, NDB_THREAD_PRIO_HIGH, NDB_THREAD_PRIO_MEAN, NDB_THREAD_PRIO_LOW, NDB_THREAD_PRIO_LOWEST } |
Functions | |
| NdbThread * | NdbThread_Create (NDB_THREAD_FUNC *p_thread_func, NDB_THREAD_ARG *p_thread_arg, const NDB_THREAD_STACKSIZE thread_stack_size, const char *p_thread_name, NDB_THREAD_PRIO thread_prio) |
| void | NdbThread_Destroy (struct NdbThread **p_thread) |
| int | NdbThread_WaitFor (struct NdbThread *p_wait_thread, void **status) |
| void | NdbThread_Exit (void *status) |
| int | NdbThread_SetConcurrencyLevel (int level) |
| typedef void* NDB_THREAD_ARG |
Definition at line 35 of file NdbThread.h.
| typedef void*( NDB_THREAD_FUNC)(void *) |
Definition at line 34 of file NdbThread.h.
| typedef enum NDB_THREAD_PRIO_ENUM NDB_THREAD_PRIO |
| typedef size_t NDB_THREAD_STACKSIZE |
Definition at line 36 of file NdbThread.h.
| enum NDB_THREAD_PRIO_ENUM |
| NDB_THREAD_PRIO_HIGHEST | |
| NDB_THREAD_PRIO_HIGH | |
| NDB_THREAD_PRIO_MEAN | |
| NDB_THREAD_PRIO_LOW | |
| NDB_THREAD_PRIO_LOWEST |
Definition at line 26 of file NdbThread.h.
00026 { 00027 NDB_THREAD_PRIO_HIGHEST, 00028 NDB_THREAD_PRIO_HIGH, 00029 NDB_THREAD_PRIO_MEAN, 00030 NDB_THREAD_PRIO_LOW, 00031 NDB_THREAD_PRIO_LOWEST 00032 } NDB_THREAD_PRIO;
| struct NdbThread* NdbThread_Create | ( | NDB_THREAD_FUNC * | p_thread_func, | |
| NDB_THREAD_ARG * | p_thread_arg, | |||
| const NDB_THREAD_STACKSIZE | thread_stack_size, | |||
| const char * | p_thread_name, | |||
| NDB_THREAD_PRIO | thread_prio | |||
| ) |
Create a thread
* p_thread_func: pointer of the function to run in the thread * p_thread_arg: pointer to argument to be passed to the thread * thread_stack_size: stack size for this thread * p_thread_name: pointer to name of this thread * returnvalue: pointer to the created thread
Definition at line 92 of file NdbThread.c.
References assert, HANDLE, NdbThread::hThread, malloc, MAX_THREAD_NAME, NDB_THREAD_PRIO_HIGH, NDB_THREAD_PRIO_HIGHEST, NDB_THREAD_PRIO_LOW, NDB_THREAD_PRIO_LOWEST, NDB_THREAD_PRIO_MEAN, NdbThread::nThreadId, and NdbThread::thread_name.
Referenced by CommandInterpreter::connect(), ArbitMgr::doStart(), WatchDog::doStart(), AsyncFile::doStart(), TransporterFacade::init(), mapSegment(), CPCD::Monitor::Monitor(), NDB_COMMAND(), NDB_MAIN(), MgmtSrvr::start(), TransporterRegistry::start_clients(), Ndb_cluster_connection::start_connect_thread(), SocketServer::startServer(), SocketServer::startSession(), and ClusterMgr::startThread().
00097 { 00098 struct NdbThread* tmpThread; 00099 int result; 00100 pthread_attr_t thread_attr; 00101 NDB_THREAD_STACKSIZE thread_stack_size= _thread_stack_size * SIZEOF_CHARP/4; 00102 00103 DBUG_ENTER("NdbThread_Create"); 00104 00105 (void)thread_prio; /* remove warning for unused parameter */ 00106 00107 if (p_thread_func == NULL) 00108 DBUG_RETURN(NULL); 00109 00110 tmpThread = (struct NdbThread*)NdbMem_Allocate(sizeof(struct NdbThread)); 00111 if (tmpThread == NULL) 00112 DBUG_RETURN(NULL); 00113 00114 DBUG_PRINT("info",("thread_name: %s", p_thread_name)); 00115 00116 strnmov(tmpThread->thread_name,p_thread_name,sizeof(tmpThread->thread_name)); 00117 00118 pthread_attr_init(&thread_attr); 00119 #ifdef PTHREAD_STACK_MIN 00120 if (thread_stack_size < PTHREAD_STACK_MIN) 00121 thread_stack_size = PTHREAD_STACK_MIN; 00122 #endif 00123 pthread_attr_setstacksize(&thread_attr, thread_stack_size); 00124 #ifdef USE_PTHREAD_EXTRAS 00125 /* Guard stack overflow with a 2k databuffer */ 00126 pthread_attr_setguardsize(&thread_attr, 2048); 00127 #endif 00128 00129 #ifdef PTHREAD_CREATE_JOINABLE /* needed on SCO */ 00130 pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_JOINABLE); 00131 #endif 00132 tmpThread->func= p_thread_func; 00133 tmpThread->object= p_thread_arg; 00134 result = pthread_create(&tmpThread->thread, 00135 &thread_attr, 00136 ndb_thread_wrapper, 00137 tmpThread); 00138 if (result != 0) 00139 { 00140 NdbMem_Free((char *)tmpThread); 00141 tmpThread = 0; 00142 } 00143 00144 pthread_attr_destroy(&thread_attr); 00145 DBUG_PRINT("exit",("ret: %lx", tmpThread)); 00146 DBUG_RETURN(tmpThread); 00147 }
Here is the caller graph for this function:

| void NdbThread_Destroy | ( | struct NdbThread ** | p_thread | ) |
Destroy a thread Deallocates memory for thread And NULL the pointer
Definition at line 150 of file NdbThread.c.
References free.
Referenced by SocketServer::checkSessionsImpl(), CommandInterpreter::connect(), CommandInterpreter::disconnect(), ArbitMgr::doStart(), TransporterFacade::doStop(), ArbitMgr::doStop(), ClusterMgr::doStop(), WatchDog::doStop(), NDB_COMMAND(), TransporterRegistry::stop_clients(), SocketServer::stopServer(), AsyncFile::~AsyncFile(), MgmtSrvr::~MgmtSrvr(), CPCD::Monitor::~Monitor(), and Ndb_cluster_connection_impl::~Ndb_cluster_connection_impl().
00151 { 00152 DBUG_ENTER("NdbThread_Destroy"); 00153 if (*p_thread != NULL){ 00154 DBUG_PRINT("enter",("*p_thread: %lx", * p_thread)); 00155 free(* p_thread); 00156 * p_thread = 0; 00157 } 00158 DBUG_VOID_RETURN; 00159 }
Here is the caller graph for this function:

| void NdbThread_Exit | ( | void * | status | ) |
Exit thread, terminates the calling thread
* status: exit code
Definition at line 178 of file NdbThread.c.
Referenced by ndb_thread_wrapper().
00179 { 00180 my_thread_end(); 00181 pthread_exit(status); 00182 }
Here is the caller graph for this function:

| int NdbThread_SetConcurrencyLevel | ( | int | level | ) |
Set thread concurrency level
*
Definition at line 185 of file NdbThread.c.
Referenced by main(), and NDB_COMMAND().
00186 { 00187 #ifdef USE_PTHREAD_EXTRAS 00188 return pthread_setconcurrency(level); 00189 #else 00190 (void)level; /* remove warning for unused parameter */ 00191 return 0; 00192 #endif 00193 }
Here is the caller graph for this function:

| int NdbThread_WaitFor | ( | struct NdbThread * | p_wait_thread, | |
| void ** | status | |||
| ) |
Waitfor a thread, suspend the execution of the calling thread until the wait_thread_id completes
* p_wait_thread, pointer to the thread to wait for * status: exit code from thread waited for * returnvalue: true = succeded, false = failed
Definition at line 162 of file NdbThread.c.
References NdbThread::hThread.
Referenced by SocketServer::checkSessionsImpl(), CommandInterpreter::connect(), CommandInterpreter::disconnect(), ArbitMgr::doStart(), TransporterFacade::doStop(), ArbitMgr::doStop(), ClusterMgr::doStop(), WatchDog::doStop(), mapSegment(), NDB_COMMAND(), NDB_MAIN(), TransporterRegistry::stop_clients(), SocketServer::stopServer(), AsyncFile::~AsyncFile(), MgmtSrvr::~MgmtSrvr(), and Ndb_cluster_connection_impl::~Ndb_cluster_connection_impl().
00163 { 00164 int result; 00165 00166 if (p_wait_thread == NULL) 00167 return 0; 00168 00169 if (p_wait_thread->thread == 0) 00170 return 0; 00171 00172 result = pthread_join(p_wait_thread->thread, status); 00173 00174 return result; 00175 }
Here is the caller graph for this function:

1.4.7

