~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/wakeup.h

  • Committer: Brian Aker
  • Date: 2010-11-17 21:25:31 UTC
  • mto: (1939.1.1 quick)
  • mto: This revision was merged to the branch mainline in revision 1940.
  • Revision ID: brian@tangent.org-20101117212531-va13j4xh43zuma68
First pass though barriers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
#include <boost/thread/mutex.hpp>
22
22
#include <boost/thread/condition_variable.hpp>
 
23
#include <boost/shared_ptr.hpp>
23
24
 
24
25
#ifndef CLIENT_WAKEUP_H
25
26
#define CLIENT_WAKEUP_H
28
29
 
29
30
// Wakeup starts in a blocking posistion
30
31
class Wakeup {
31
 
  bool sleeping;
32
 
  boost::mutex sleeper_mutex;
33
 
  boost::condition_variable_any sleep_threshhold;
34
 
 
35
32
public:
 
33
  typedef boost::shared_ptr<Wakeup> shared_ptr;
 
34
 
36
35
  Wakeup() :
37
36
    sleeping(true)
38
37
  { }
39
38
 
 
39
  // Signal all of the waiters to start
40
40
  void start()
41
41
  {
42
42
    boost::mutex::scoped_lock scopedWakeup(sleeper_mutex);
44
44
    sleep_threshhold.notify_all();
45
45
  }
46
46
 
 
47
  // reset after the start of the signal so that we can reuse the wakeup
47
48
  void reset()
48
49
  {
49
50
    boost::mutex::scoped_lock scopedWakeup(sleeper_mutex);
59
60
    }
60
61
    sleeper_mutex.unlock();
61
62
  }
 
63
 
 
64
private:
 
65
  bool sleeping;
 
66
  boost::mutex sleeper_mutex;
 
67
  boost::condition_variable_any sleep_threshhold;
62
68
};
63
69
 
64
70
} // namespace client