bumped version to 0.1.0
[beacon-ss.git] / src / beacon / detail / future_event_base.hpp
blob2b56432bb2c219e06fa7aabea59174a7eb1389b2
1 /**
2 * beacon
3 * Author: Lukas Krejci <krejci.l@centrum.cz>, (C) 2008
4 * Copyright: See COPYING file that comes with this distribution
5 */
7 #ifndef BEACON_DETAIL_FUTURE_EVENT_BASE_H
8 #define BEACON_DETAIL_FUTURE_EVENT_BASE_H
10 #include <boost/thread/mutex.hpp>
11 #include <boost/thread/condition.hpp>
12 #include <beacon/exceptions.hpp>
13 #include <beacon/reference_countable.hpp>
15 namespace beacon {
17 namespace detail {
19 //forward decl
20 class in_queue_invoke_base;
22 /**
23 * A base class for future_event class that implements the event_loop
24 * aware functionality inside the library.
26 class future_event_base : public reference_countable {
27 friend class in_queue_invoke_base;
29 typedef boost::mutex::scoped_lock lock;
31 public:
32 future_event_base() : value(0), _finished(false),
33 _waiting(false) {
36 ~future_event_base();
37 protected:
39 /** currently always fails returning false */
40 bool cancel();
41 bool finished() const;
43 void set(void * value);
44 void * get() throw (execution_exception);
45 void * get(int timeout) throw(execution_exception, timeout_exception);
47 private:
48 boost::mutex monitor;
49 boost::condition value_set;
50 void * value;
51 bool _finished;
52 bool _waiting;
55 } //namespace detail
57 } //namespace
59 #endif