@@ -21,7 +21,7 @@ pub const HYPER_POLL_READY: c_int = 0;
21
21
pub const HYPER_POLL_PENDING : c_int = 1 ;
22
22
pub const HYPER_POLL_ERROR : c_int = 3 ;
23
23
24
- pub struct Exec {
24
+ pub struct hyper_executor {
25
25
/// The executor of all task futures.
26
26
///
27
27
/// There should never be contention on the mutex, as it is only locked
@@ -38,23 +38,23 @@ pub struct Exec {
38
38
spawn_queue : Mutex < Vec < TaskFuture > > ,
39
39
40
40
/// This is used to track when a future calls `wake` while we are within
41
- /// `Exec ::poll_next`.
41
+ /// `hyper_executor ::poll_next`.
42
42
is_woken : Arc < ExecWaker > ,
43
43
}
44
44
45
45
#[ derive( Clone ) ]
46
- pub ( crate ) struct WeakExec ( Weak < Exec > ) ;
46
+ pub ( crate ) struct WeakExec ( Weak < hyper_executor > ) ;
47
47
48
48
struct ExecWaker ( AtomicBool ) ;
49
49
50
- pub struct Task {
50
+ pub struct hyper_task {
51
51
future : BoxFuture < BoxAny > ,
52
52
output : Option < BoxAny > ,
53
53
userdata : UserDataPointer ,
54
54
}
55
55
56
56
struct TaskFuture {
57
- task : Option < Box < Task > > ,
57
+ task : Option < Box < hyper_task > > ,
58
58
}
59
59
60
60
pub struct hyper_context < ' a > ( Context < ' a > ) ;
@@ -85,29 +85,29 @@ pub(crate) trait IntoDynTaskType {
85
85
fn into_dyn_task_type ( self ) -> BoxAny ;
86
86
}
87
87
88
- // ===== impl Exec =====
88
+ // ===== impl hyper_executor =====
89
89
90
- impl Exec {
91
- fn new ( ) -> Arc < Exec > {
92
- Arc :: new ( Exec {
90
+ impl hyper_executor {
91
+ fn new ( ) -> Arc < hyper_executor > {
92
+ Arc :: new ( hyper_executor {
93
93
driver : Mutex :: new ( FuturesUnordered :: new ( ) ) ,
94
94
spawn_queue : Mutex :: new ( Vec :: new ( ) ) ,
95
95
is_woken : Arc :: new ( ExecWaker ( AtomicBool :: new ( false ) ) ) ,
96
96
} )
97
97
}
98
98
99
- pub ( crate ) fn downgrade ( exec : & Arc < Exec > ) -> WeakExec {
99
+ pub ( crate ) fn downgrade ( exec : & Arc < hyper_executor > ) -> WeakExec {
100
100
WeakExec ( Arc :: downgrade ( exec) )
101
101
}
102
102
103
- fn spawn ( & self , task : Box < Task > ) {
103
+ fn spawn ( & self , task : Box < hyper_task > ) {
104
104
self . spawn_queue
105
105
. lock ( )
106
106
. unwrap ( )
107
107
. push ( TaskFuture { task : Some ( task) } ) ;
108
108
}
109
109
110
- fn poll_next ( & self ) -> Option < Box < Task > > {
110
+ fn poll_next ( & self ) -> Option < Box < hyper_task > > {
111
111
// Drain the queue first.
112
112
self . drain_queue ( ) ;
113
113
@@ -169,21 +169,21 @@ impl WeakExec {
169
169
impl crate :: rt:: Executor < BoxFuture < ( ) > > for WeakExec {
170
170
fn execute ( & self , fut : BoxFuture < ( ) > ) {
171
171
if let Some ( exec) = self . 0 . upgrade ( ) {
172
- exec. spawn ( Task :: boxed ( fut) ) ;
172
+ exec. spawn ( hyper_task :: boxed ( fut) ) ;
173
173
}
174
174
}
175
175
}
176
176
177
177
ffi_fn ! {
178
178
/// Creates a new task executor.
179
- fn hyper_executor_new( ) -> * const Exec {
180
- Arc :: into_raw( Exec :: new( ) )
179
+ fn hyper_executor_new( ) -> * const hyper_executor {
180
+ Arc :: into_raw( hyper_executor :: new( ) )
181
181
}
182
182
}
183
183
184
184
ffi_fn ! {
185
185
/// Frees an executor and any incomplete tasks still part of it.
186
- fn hyper_executor_free( exec: * const Exec ) {
186
+ fn hyper_executor_free( exec: * const hyper_executor ) {
187
187
drop( unsafe { Arc :: from_raw( exec) } ) ;
188
188
}
189
189
}
@@ -193,7 +193,7 @@ ffi_fn! {
193
193
///
194
194
/// The executor takes ownership of the task, it should not be accessed
195
195
/// again unless returned back to the user with `hyper_executor_poll`.
196
- fn hyper_executor_push( exec: * const Exec , task: * mut Task ) -> hyper_code {
196
+ fn hyper_executor_push( exec: * const hyper_executor , task: * mut hyper_task ) -> hyper_code {
197
197
if exec. is_null( ) || task. is_null( ) {
198
198
return hyper_code:: HYPERE_INVALID_ARG ;
199
199
}
@@ -211,7 +211,7 @@ ffi_fn! {
211
211
/// If ready, returns a task from the executor that has completed.
212
212
///
213
213
/// If there are no ready tasks, this returns `NULL`.
214
- fn hyper_executor_poll( exec: * const Exec ) -> * mut Task {
214
+ fn hyper_executor_poll( exec: * const hyper_executor ) -> * mut hyper_task {
215
215
// We only want an `&Arc` in here, so wrap in a `ManuallyDrop` so we
216
216
// don't accidentally trigger a ref_dec of the Arc.
217
217
let exec = unsafe { & * exec } ;
@@ -222,15 +222,15 @@ ffi_fn! {
222
222
}
223
223
}
224
224
225
- // ===== impl Task =====
225
+ // ===== impl hyper_task =====
226
226
227
- impl Task {
228
- pub ( crate ) fn boxed < F > ( fut : F ) -> Box < Task >
227
+ impl hyper_task {
228
+ pub ( crate ) fn boxed < F > ( fut : F ) -> Box < hyper_task >
229
229
where
230
230
F : Future + Send + ' static ,
231
231
F :: Output : IntoDynTaskType + Send + Sync + ' static ,
232
232
{
233
- Box :: new ( Task {
233
+ Box :: new ( hyper_task {
234
234
future : Box :: pin ( async move { fut. await . into_dyn_task_type ( ) } ) ,
235
235
output : None ,
236
236
userdata : UserDataPointer ( ptr:: null_mut ( ) ) ,
@@ -246,7 +246,7 @@ impl Task {
246
246
}
247
247
248
248
impl Future for TaskFuture {
249
- type Output = Box < Task > ;
249
+ type Output = Box < hyper_task > ;
250
250
251
251
fn poll ( mut self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Self :: Output > {
252
252
match Pin :: new ( & mut self . task . as_mut ( ) . unwrap ( ) . future ) . poll ( cx) {
@@ -262,7 +262,7 @@ impl Future for TaskFuture {
262
262
263
263
ffi_fn ! {
264
264
/// Free a task.
265
- fn hyper_task_free( task: * mut Task ) {
265
+ fn hyper_task_free( task: * mut hyper_task ) {
266
266
drop( unsafe { Box :: from_raw( task) } ) ;
267
267
}
268
268
}
@@ -274,7 +274,7 @@ ffi_fn! {
274
274
/// this task.
275
275
///
276
276
/// Use `hyper_task_type` to determine the type of the `void *` return value.
277
- fn hyper_task_value( task: * mut Task ) -> * mut c_void {
277
+ fn hyper_task_value( task: * mut hyper_task ) -> * mut c_void {
278
278
if task. is_null( ) {
279
279
return ptr:: null_mut( ) ;
280
280
}
@@ -297,7 +297,7 @@ ffi_fn! {
297
297
298
298
ffi_fn ! {
299
299
/// Query the return type of this task.
300
- fn hyper_task_type( task: * mut Task ) -> hyper_task_return_type {
300
+ fn hyper_task_type( task: * mut hyper_task ) -> hyper_task_return_type {
301
301
if task. is_null( ) {
302
302
// instead of blowing up spectacularly, just say this null task
303
303
// doesn't have a value to retrieve.
@@ -313,7 +313,7 @@ ffi_fn! {
313
313
///
314
314
/// This value will be passed to task callbacks, and can be checked later
315
315
/// with `hyper_task_userdata`.
316
- fn hyper_task_set_userdata( task: * mut Task , userdata: * mut c_void) {
316
+ fn hyper_task_set_userdata( task: * mut hyper_task , userdata: * mut c_void) {
317
317
if task. is_null( ) {
318
318
return ;
319
319
}
@@ -324,7 +324,7 @@ ffi_fn! {
324
324
325
325
ffi_fn ! {
326
326
/// Retrieve the userdata that has been set via `hyper_task_set_userdata`.
327
- fn hyper_task_userdata( task: * mut Task ) -> * mut c_void {
327
+ fn hyper_task_userdata( task: * mut hyper_task ) -> * mut c_void {
328
328
if task. is_null( ) {
329
329
return ptr:: null_mut( ) ;
330
330
}
0 commit comments