Revision 1236 branches/threaded2merge/src/linad99/thread_stuff.cpp

thread_stuff.cpp (revision 1236)
914 914
  s = 0;
915 915
  return x;
916 916
}
917

  
918
adthread_buffer::adthread_buffer()
919
{
920
}
921
adthread_buffer::adthread_buffer(const adthread_buffer& other)
922
{
923
}
924
adthread_buffer::~adthread_buffer()
925
{
926
}
927
void adthread_buffer::lock()
928
{
929
  pthread_mutex_init(&mutex, NULL);
930
  pthread_cond_init(&condition, NULL);
931
  locked = true;
932
  pthread_mutex_lock(&mutex);
933
  while (locked)
934
  {
935
    pthread_cond_wait(&condition, &mutex);
936
  }
937
}
938
void adthread_buffer::unlock()
939
{
940
  locked = false;
941
  pthread_cond_signal(&condition);
942
  pthread_mutex_unlock(&mutex);
943
}

Also available in: Unified diff