renamed from beacon to beacons, bumped version to 0.1.1 for that.
[beacon-ss.git] / src / beacons / future_event.hpp
blob6b080f758391d253fea91b31a193309ceabaf68f
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 BEACONS_FUTURE_EVENT_H
8 #define BEACONS_FUTURE_EVENT_H
10 #include <beacons/future.hpp>
11 #include <beacons/detail/future_event_base.hpp>
13 namespace beacons {
15 /**
16 * An implementation of the future interface that cooperates with
17 * {@link event_loop}.
19 template<typename ResultType>
20 class future_event : public future<ResultType>, public detail::future_event_base {
21 public:
23 future_event() : future_event_base() {
26 /** currently always fails returning false */
27 bool cancel() {
28 return this->future_event_base::cancel();
31 bool finished() const {
32 return this->future_event_base::finished();
35 ResultType get() throw (execution_exception) {
36 ResultType * ret = static_cast<ResultType *>(this->future_event_base::get());
38 return *ret;
41 ResultType get(int timeout) throw(execution_exception, timeout_exception) {
42 ResultType * ret = static_cast<ResultType *>(this->future_event_base::get(timeout));
44 return *ret;
48 template<>
49 class future_event<void> : public future<void>, public detail::future_event_base {
50 public:
52 future_event() : future_event_base() {
55 /** currently always fails returning false */
56 bool cancel() {
57 return this->future_event_base::cancel();
60 bool finished() const {
61 return this->future_event_base::finished();
64 void get() throw (execution_exception) {
65 this->future_event_base::get();
68 void get(int timeout) throw(execution_exception, timeout_exception) {
69 this->future_event_base::get();
75 #endif