19 #include <ndb_global.h> 
   20 #include <NDBT_Thread.hpp> 
   23 NDBT_Thread::NDBT_Thread()
 
   28 NDBT_Thread::NDBT_Thread(
NDBT_ThreadSet* thread_set, 
int thread_no)
 
   30   create(thread_set, thread_no);
 
   36   m_magic = NDBT_Thread::Magic;
 
   39   m_thread_set = thread_set;
 
   40   m_thread_no = thread_no;
 
   47   m_mutex = NdbMutex_Create();
 
   49   m_cond = NdbCondition_Create();
 
   53   sprintf(buf, 
"NDBT_%04u", (
unsigned)thread_no);
 
   54   const char* 
name = strdup(buf);
 
   57   unsigned stacksize = 512 * 1024;
 
   58   NDB_THREAD_PRIO prio = NDB_THREAD_PRIO_LOW;
 
   59   m_thread = NdbThread_Create(NDBT_Thread_run,
 
   60                               (
void**)
this, stacksize, name, prio);
 
   61   assert(m_thread != 0);
 
   64 NDBT_Thread::~NDBT_Thread()
 
   67     NdbThread_Destroy(&m_thread);
 
   71     NdbCondition_Destroy(m_cond);
 
   75     NdbMutex_Destroy(m_mutex);
 
   81 NDBT_Thread_run(
void* arg)
 
   85   assert(thr.m_magic == NDBT_Thread::Magic);
 
   95     while (m_state != Start && m_state != Exit) {
 
   98     if (m_state == Exit) {
 
  124   while (m_state != Stop)
 
  142   NdbThread_WaitFor(m_thread, &m_status);
 
  149   m_ndb = 
new Ndb(ncc, db);
 
  150   if (m_ndb->
init() == -1 ||
 
  159 NDBT_Thread::disconnect()
 
  167 NDBT_ThreadSet::NDBT_ThreadSet(
int count)
 
  171   for (
int n = 0; 
n < count; 
n++) {
 
  176 NDBT_ThreadSet::~NDBT_ThreadSet()
 
  178   for (
int n = 0; 
n < m_count; 
n++) {
 
  186 NDBT_ThreadSet::start()
 
  188   for (
int n = 0; 
n < m_count; 
n++) {
 
  195 NDBT_ThreadSet::stop()
 
  197   for (
int n = 0; 
n < m_count; 
n++) {
 
  204 NDBT_ThreadSet::exit()
 
  206   for (
int n = 0; 
n < m_count; 
n++) {
 
  213 NDBT_ThreadSet::join()
 
  215   for (
int n = 0; 
n < m_count; 
n++) {
 
  222 NDBT_ThreadSet::set_func(NDBT_ThreadFunc* func)
 
  224   for (
int n = 0; 
n < m_count; 
n++) {
 
  231 NDBT_ThreadSet::set_input(
const void* input)
 
  233   for (
int n = 0; 
n < m_count; 
n++) {
 
  235     thr.set_input(input);
 
  240 NDBT_ThreadSet::delete_output()
 
  242   for (
int n = 0; 
n < m_count; 
n++) {
 
  243     if (m_thread[
n] != 0) {
 
  253   for (
int n = 0; 
n < m_count; 
n++) {
 
  254     assert(m_thread[
n] != 0);
 
  256     if (thr.connect(ncc, db) == -1)
 
  263 NDBT_ThreadSet::disconnect()
 
  265   for (
int n = 0; 
n < m_count; 
n++) {
 
  266     if (m_thread[
n] != 0) {
 
  274 NDBT_ThreadSet::get_err()
 const 
  276   for (
int n = 0; 
n < m_count; 
n++) {
 
  277     if (m_thread[
n] != 0) {
 
  279       int err = thr.get_err();