forked from solidoss/solidframe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreactorcontext.hpp
99 lines (77 loc) · 1.81 KB
/
reactorcontext.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
// solid/frame/aio/reactorcontext.hpp
//
// Copyright (c) 2015 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_REACTORCONTEXT_HPP
#define SOLID_FRAME_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;
class Object;
class Reactor;
class CompletionHandler;
struct ReactorContext{
~ReactorContext(){
}
const NanoTime& time()const{
return rcrttm;
}
ErrorCodeT const& systemError()const{
return syserr;
}
ErrorConditionT const& error()const{
return err;
}
Object& object()const;
Service& service()const;
UniqueId objectUid()const;
void clearError(){
err.clear();
syserr.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 reactevn;
}
CompletionHandler* completionHandler()const;
void error(ErrorConditionT const& _err){
err = _err;
}
void systemError(ErrorCodeT const& _err){
syserr = _err;
}
ReactorContext(
Reactor &_rreactor,
const NanoTime &_rcrttm
): rreactor(_rreactor),
rcrttm(_rcrttm), chnidx(-1), objidx(-1), reactevn(ReactorEventNone){}
Reactor &rreactor;
const NanoTime &rcrttm;
size_t chnidx;
size_t objidx;
ReactorEventsE reactevn;
ErrorCodeT syserr;
ErrorConditionT err;
};
}//namespace frame
}//namespace solid
#endif