forked from solidoss/solidframe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaioreactorcontext.hpp
103 lines (79 loc) · 1.98 KB
/
aioreactorcontext.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// solid/frame/aio/aioreactorcontext.hpp
//
// Copyright (c) 2014 Valentin Palade (vipalade @ gmail . com)
//
// This file is part of SolidFrame framework.
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.
//
#ifndef SOLID_FRAME_AIO_REACTORCONTEXT_HPP
#define SOLID_FRAME_AIO_REACTORCONTEXT_HPP
#include "solid/system/common.hpp"
#include "solid/system/error.hpp"
#include "solid/system/socketdevice.hpp"
#include "solid/system/nanotime.hpp"
#include "solid/frame/aio/aiocommon.hpp"
namespace solid{
namespace frame{
class Service;
namespace aio{
class Object;
class Reactor;
class CompletionHandler;
struct ReactorContext{
~ReactorContext(){
}
const NanoTime& time()const{
return rcurrent_time_;
}
ErrorCodeT const& systemError()const{
return system_error_;
}
ErrorConditionT const& error()const{
return error_;
}
Object& object()const;
Service& service()const;
UniqueId objectUid()const;
void clearError(){
error_.clear();
system_error_.clear();
}
private:
friend class CompletionHandler;
friend class Reactor;
friend class Object;
Reactor& reactor(){
return rreactor_;
}
Reactor const& reactor()const{
return rreactor_;
}
ReactorEventsE reactorEvent()const{
return reactor_event_;
}
CompletionHandler* completionHandler()const;
void error(ErrorConditionT const& _err){
error_ = _err;
}
void systemError(ErrorCodeT const& _err){
system_error_ = _err;
}
ReactorContext(
Reactor &_rreactor,
const NanoTime &_rcurrent_time
): rreactor_(_rreactor),
rcurrent_time_(_rcurrent_time), channel_index_(-1), object_index_(-1), reactor_event_(ReactorEventNone){}
Reactor &rreactor_;
const NanoTime &rcurrent_time_;
size_t channel_index_;
size_t object_index_;
ReactorEventsE reactor_event_;
ErrorCodeT system_error_;
ErrorConditionT error_;
};
}//namespace aio
}//namespace frame
}//namespace solid
#endif