Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Private Attributes
Arc::SimpleCondition Class Reference

Helper function to create simple thread. More...

#include <Thread.h>

List of all members.

Public Member Functions

 SimpleCondition (void)
 ~SimpleCondition (void)
void lock (void)
 Acquire semaphor.
void unlock (void)
 Release semaphor.
void signal (void)
 Signal about condition.
void signal_nonblock (void)
 Signal about condition without using semaphor.
void broadcast (void)
 Signal about condition to all waiting threads.
void wait (void)
 Wait for condition.
void wait_nonblock (void)
 Wait for condition without using semaphor.
bool wait (int t)
 Wait for condition no longer than t milliseconds.
void reset (void)
 Reset object to initial state.

Private Attributes

Glib::Cond cond_
Glib::Mutex lock_
bool flag_

Detailed Description

Helper function to create simple thread.

It takes care of all pecularities of Glib::Thread API. As result it runs function 'func' with argument 'arg' in a separate thread. The created thread will be joinable. Returns true on success. This function is currently disable becaueit is not clear if joinability is a needed feature Simple triggered condition. Provides condition and semaphor objects in one element.

Definition at line 63 of file Thread.h.


Constructor & Destructor Documentation

Definition at line 69 of file Thread.h.

      : flag_(false) {}

Definition at line 71 of file Thread.h.

                           {
      /* race condition ? */
      broadcast();
    }

Here is the call graph for this function:


Member Function Documentation

void Arc::SimpleCondition::broadcast ( void  ) [inline]

Signal about condition to all waiting threads.

Definition at line 96 of file Thread.h.

                         {
      lock_.lock();
      flag_ = true;
      cond_.broadcast();
      lock_.unlock();
    }

Here is the caller graph for this function:

void Arc::SimpleCondition::lock ( void  ) [inline]

Acquire semaphor.

Definition at line 76 of file Thread.h.

                    {
      lock_.lock();
    }

Here is the caller graph for this function:

void Arc::SimpleCondition::reset ( void  ) [inline]

Reset object to initial state.

Definition at line 133 of file Thread.h.

                     {
      lock_.lock();
      flag_ = false;
      lock_.unlock();
    }

Here is the caller graph for this function:

void Arc::SimpleCondition::signal ( void  ) [inline]

Signal about condition.

Definition at line 84 of file Thread.h.

                      {
      lock_.lock();
      flag_ = true;
      cond_.signal();
      lock_.unlock();
    }

Here is the caller graph for this function:

void Arc::SimpleCondition::signal_nonblock ( void  ) [inline]

Signal about condition without using semaphor.

Definition at line 91 of file Thread.h.

                               {
      flag_ = true;
      cond_.signal();
    }

Here is the caller graph for this function:

void Arc::SimpleCondition::unlock ( void  ) [inline]

Release semaphor.

Definition at line 80 of file Thread.h.

                      {
      lock_.unlock();
    }

Here is the caller graph for this function:

void Arc::SimpleCondition::wait ( void  ) [inline]

Wait for condition.

Definition at line 103 of file Thread.h.

                    {
      lock_.lock();
      while (!flag_)
        cond_.wait(lock_);
      flag_ = false;
      lock_.unlock();
    }

Here is the caller graph for this function:

bool Arc::SimpleCondition::wait ( int  t) [inline]

Wait for condition no longer than t milliseconds.

Definition at line 117 of file Thread.h.

                     {
      lock_.lock();
      Glib::TimeVal etime;
      etime.assign_current_time();
      etime.add_milliseconds(t);
      bool res(true);
      while (!flag_) {
        res = cond_.timed_wait(lock_, etime);
        if (!res)
          break;
      }
      flag_ = false;
      lock_.unlock();
      return res;
    }
void Arc::SimpleCondition::wait_nonblock ( void  ) [inline]

Wait for condition without using semaphor.

Definition at line 111 of file Thread.h.

                             {
      while (!flag_)
        cond_.wait(lock_);
      flag_ = false;
    }

Here is the caller graph for this function:


Member Data Documentation

Glib::Cond Arc::SimpleCondition::cond_ [private]

Definition at line 65 of file Thread.h.

Definition at line 67 of file Thread.h.

Glib::Mutex Arc::SimpleCondition::lock_ [private]

Definition at line 66 of file Thread.h.


The documentation for this class was generated from the following file: