~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/wakeup.h

  • Committer: Monty Taylor
  • Date: 2010-11-08 18:26:08 UTC
  • mto: This revision was merged to the branch mainline in revision 1931.
  • Revision ID: mordred@inaugust.com-20101108182608-lci86acl7r53sbi3
Replaced auto_ptr with scoped_ptr.

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>
24
23
 
25
24
#ifndef CLIENT_WAKEUP_H
26
25
#define CLIENT_WAKEUP_H
29
28
 
30
29
// Wakeup starts in a blocking posistion
31
30
class Wakeup {
 
31
  bool sleeping;
 
32
  boost::mutex sleeper_mutex;
 
33
  boost::condition_variable_any sleep_threshhold;
 
34
 
32
35
public:
33
 
  typedef boost::shared_ptr<Wakeup> shared_ptr;
34
 
 
35
36
  Wakeup() :
36
37
    sleeping(true)
37
38
  { }
38
39
 
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
48
47
  void reset()
49
48
  {
50
49
    boost::mutex::scoped_lock scopedWakeup(sleeper_mutex);
60
59
    }
61
60
    sleeper_mutex.unlock();
62
61
  }
63
 
 
64
 
private:
65
 
  bool sleeping;
66
 
  boost::mutex sleeper_mutex;
67
 
  boost::condition_variable_any sleep_threshhold;
68
62
};
69
63
 
70
64
} // namespace client