@@ -7,11 +7,19 @@ struct ServerState {
7
7
application_state : ApplicationState ,
8
8
}
9
9
pub struct ApplicationState {
10
- s0 : alloc:: sync:: Arc < app:: Custom > ,
10
+ s0 : alloc:: sync:: Arc < std:: sync:: RwLock < app:: Custom > > ,
11
+ s1 : alloc:: sync:: Arc < app:: Custom > ,
12
+ s2 : alloc:: sync:: Arc < std:: sync:: Mutex < app:: Custom > > ,
11
13
}
12
14
pub async fn build_application_state ( ) -> crate :: ApplicationState {
13
- let v0 = app:: constructor ( ) ;
14
- crate :: ApplicationState { s0 : v0 }
15
+ let v0 = app:: arc_mutex ( ) ;
16
+ let v1 = app:: arc ( ) ;
17
+ let v2 = app:: arc_rwlock ( ) ;
18
+ crate :: ApplicationState {
19
+ s0 : v2,
20
+ s1 : v1,
21
+ s2 : v0,
22
+ }
15
23
}
16
24
pub fn run (
17
25
server_builder : pavex:: server:: Server ,
@@ -56,7 +64,12 @@ async fn route_request(
56
64
0u32 => {
57
65
match & request_head. method {
58
66
& pavex:: http:: Method :: GET => {
59
- route_0:: entrypoint ( & server_state. application_state . s0 ) . await
67
+ route_0:: entrypoint (
68
+ & server_state. application_state . s0 ,
69
+ & server_state. application_state . s1 ,
70
+ & server_state. application_state . s2 ,
71
+ )
72
+ . await
60
73
}
61
74
_ => {
62
75
let allowed_methods: pavex:: router:: AllowedMethods = pavex:: router:: MethodAllowList :: from_iter ( [
@@ -71,50 +84,66 @@ async fn route_request(
71
84
}
72
85
}
73
86
pub mod route_0 {
74
- pub async fn entrypoint < ' a > (
75
- s_0 : & ' a alloc:: sync:: Arc < app:: Custom > ,
87
+ pub async fn entrypoint < ' a , ' b , ' c > (
88
+ s_0 : & ' a alloc:: sync:: Arc < std:: sync:: RwLock < app:: Custom > > ,
89
+ s_1 : & ' b alloc:: sync:: Arc < app:: Custom > ,
90
+ s_2 : & ' c alloc:: sync:: Arc < std:: sync:: Mutex < app:: Custom > > ,
76
91
) -> pavex:: response:: Response {
77
- let response = wrapping_0 ( s_0) . await ;
92
+ let response = wrapping_0 ( s_0, s_1 , s_2 ) . await ;
78
93
response
79
94
}
80
- async fn stage_1 < ' a > (
81
- s_0 : & ' a alloc:: sync:: Arc < app:: Custom > ,
95
+ async fn stage_1 < ' a , ' b , ' c > (
96
+ s_0 : & ' a alloc:: sync:: Arc < std:: sync:: Mutex < app:: Custom > > ,
97
+ s_1 : & ' b alloc:: sync:: Arc < std:: sync:: RwLock < app:: Custom > > ,
98
+ s_2 : & ' c alloc:: sync:: Arc < app:: Custom > ,
82
99
) -> pavex:: response:: Response {
83
- let response = handler ( s_0) . await ;
100
+ let response = handler ( s_0, s_1 , s_2 ) . await ;
84
101
response
85
102
}
86
103
async fn wrapping_0 (
87
- v0 : & alloc:: sync:: Arc < app:: Custom > ,
104
+ v0 : & alloc:: sync:: Arc < std:: sync:: RwLock < app:: Custom > > ,
105
+ v1 : & alloc:: sync:: Arc < app:: Custom > ,
106
+ v2 : & alloc:: sync:: Arc < std:: sync:: Mutex < app:: Custom > > ,
88
107
) -> pavex:: response:: Response {
89
- let v1 = crate :: route_0:: Next0 {
90
- s_0 : v0,
108
+ let v3 = crate :: route_0:: Next0 {
109
+ s_0 : v2,
110
+ s_1 : v0,
111
+ s_2 : v1,
91
112
next : stage_1,
92
113
} ;
93
- let v2 = pavex:: middleware:: Next :: new ( v1 ) ;
94
- let v3 = pavex:: middleware:: wrap_noop ( v2 ) . await ;
95
- <pavex:: response:: Response as pavex:: response:: IntoResponse >:: into_response ( v3 )
114
+ let v4 = pavex:: middleware:: Next :: new ( v3 ) ;
115
+ let v5 = pavex:: middleware:: wrap_noop ( v4 ) . await ;
116
+ <pavex:: response:: Response as pavex:: response:: IntoResponse >:: into_response ( v5 )
96
117
}
97
118
async fn handler (
98
- v0 : & alloc:: sync:: Arc < app:: Custom > ,
119
+ v0 : & alloc:: sync:: Arc < std:: sync:: Mutex < app:: Custom > > ,
120
+ v1 : & alloc:: sync:: Arc < std:: sync:: RwLock < app:: Custom > > ,
121
+ v2 : & alloc:: sync:: Arc < app:: Custom > ,
99
122
) -> pavex:: response:: Response {
100
- let v1 = app:: handler ( v0 ) ;
101
- <http:: StatusCode as pavex:: response:: IntoResponse >:: into_response ( v1 )
123
+ let v3 = app:: handler ( v2 , v0 , v1 ) ;
124
+ <http:: StatusCode as pavex:: response:: IntoResponse >:: into_response ( v3 )
102
125
}
103
- struct Next0 < ' a , T >
126
+ struct Next0 < ' a , ' b , ' c , T >
104
127
where
105
128
T : std:: future:: Future < Output = pavex:: response:: Response > ,
106
129
{
107
- s_0 : & ' a alloc:: sync:: Arc < app:: Custom > ,
108
- next : fn ( & ' a alloc:: sync:: Arc < app:: Custom > ) -> T ,
130
+ s_0 : & ' a alloc:: sync:: Arc < std:: sync:: Mutex < app:: Custom > > ,
131
+ s_1 : & ' b alloc:: sync:: Arc < std:: sync:: RwLock < app:: Custom > > ,
132
+ s_2 : & ' c alloc:: sync:: Arc < app:: Custom > ,
133
+ next : fn (
134
+ & ' a alloc:: sync:: Arc < std:: sync:: Mutex < app:: Custom > > ,
135
+ & ' b alloc:: sync:: Arc < std:: sync:: RwLock < app:: Custom > > ,
136
+ & ' c alloc:: sync:: Arc < app:: Custom > ,
137
+ ) -> T ,
109
138
}
110
- impl < ' a , T > std:: future:: IntoFuture for Next0 < ' a , T >
139
+ impl < ' a , ' b , ' c , T > std:: future:: IntoFuture for Next0 < ' a , ' b , ' c , T >
111
140
where
112
141
T : std:: future:: Future < Output = pavex:: response:: Response > ,
113
142
{
114
143
type Output = pavex:: response:: Response ;
115
144
type IntoFuture = T ;
116
145
fn into_future ( self ) -> Self :: IntoFuture {
117
- ( self . next ) ( self . s_0 )
146
+ ( self . next ) ( self . s_0 , self . s_1 , self . s_2 )
118
147
}
119
148
}
120
149
}
0 commit comments