@@ -19,6 +19,7 @@ use compio_driver::{
19
19
use compio_log:: { debug, instrument} ;
20
20
use crossbeam_queue:: SegQueue ;
21
21
use futures_util:: { future:: Either , FutureExt } ;
22
+ use send_wrapper:: SendWrapper ;
22
23
use smallvec:: SmallVec ;
23
24
24
25
pub ( crate ) mod op;
@@ -47,7 +48,7 @@ impl Default for FutureState {
47
48
48
49
pub ( crate ) struct RuntimeInner {
49
50
driver : RefCell < Proactor > ,
50
- local_runnables : Arc < RefCell < VecDeque < Runnable > > > ,
51
+ local_runnables : SendWrapper < Arc < RefCell < VecDeque < Runnable > > > > ,
51
52
sync_runnables : Arc < SegQueue < Runnable > > ,
52
53
op_runtime : RefCell < OpRuntime > ,
53
54
#[ cfg( feature = "time" ) ]
@@ -60,7 +61,7 @@ impl RuntimeInner {
60
61
driver : RefCell :: new ( builder. build ( ) ?) ,
61
62
// Arc to send to another thread, but only in current thread will the inner be accessed.
62
63
#[ allow( clippy:: arc_with_non_send_sync) ]
63
- local_runnables : Arc :: new ( RefCell :: new ( VecDeque :: new ( ) ) ) ,
64
+ local_runnables : SendWrapper :: new ( Arc :: new ( RefCell :: new ( VecDeque :: new ( ) ) ) ) ,
64
65
sync_runnables : Arc :: new ( SegQueue :: new ( ) ) ,
65
66
op_runtime : RefCell :: default ( ) ,
66
67
#[ cfg( feature = "time" ) ]
@@ -77,10 +78,8 @@ impl RuntimeInner {
77
78
. borrow ( )
78
79
. handle ( )
79
80
. expect ( "cannot create notify handle of the proactor" ) ;
80
- let main_id = std:: thread:: current ( ) . id ( ) ;
81
81
let schedule = move |runnable| {
82
- let in_current_thread = main_id == std:: thread:: current ( ) . id ( ) ;
83
- if in_current_thread {
82
+ if local_runnables. valid ( ) {
84
83
local_runnables. borrow_mut ( ) . push_back ( runnable) ;
85
84
} else {
86
85
sync_runnables. push ( runnable) ;
0 commit comments