@@ -213,8 +213,8 @@ impl JsRuntimeInspectorState {
213
213
214
214
loop {
215
215
// current_state -> PollState::Polling
216
- // starts polling for session_rx -> must be non-ready
217
- // self.established is empty - must be pending/poll::ready(None)
216
+ // starts polling for new_io_session_rx -> must be non-ready
217
+ // self.io_session_futures is empty - must be pending/poll::ready(None)
218
218
sessions. pump_messages_for_remote_sessions ( cx) ;
219
219
220
220
// current_state -> PollState::Polling
@@ -285,7 +285,8 @@ impl JsRuntimeInspector {
285
285
context : v8:: Local < v8:: Context > ,
286
286
is_main_runtime : bool ,
287
287
) -> Rc < Self > {
288
- let ( new_session_tx, new_session_rx) = mpsc:: unbounded :: < NewSessionTxMsg > ( ) ;
288
+ let ( new_session_tx, new_new_io_session_rx) =
289
+ mpsc:: unbounded :: < NewSessionTxMsg > ( ) ;
289
290
290
291
let waker = InspectorWaker :: new ( scope. thread_safe_handle ( ) ) ;
291
292
@@ -308,7 +309,7 @@ impl JsRuntimeInspector {
308
309
309
310
* state. sessions . borrow_mut ( ) = SessionContainer :: new (
310
311
v8_inspector. clone ( ) ,
311
- new_session_rx ,
312
+ new_new_io_session_rx ,
312
313
state. is_dispatching_message . clone ( ) ,
313
314
) ;
314
315
@@ -320,7 +321,7 @@ impl JsRuntimeInspector {
320
321
} ) ;
321
322
322
323
inspector. context_created ( context, is_main_runtime) ;
323
- // TODO(bartlomieju): we need to only poll `session_rx ` once - just
324
+ // TODO(bartlomieju): we need to only poll `new_io_session_rx ` once - just
324
325
// to register the task context, at this point it's guaranteed there are
325
326
// senders, so no need to call the complicated `poll_sessions`.
326
327
@@ -404,7 +405,7 @@ impl JsRuntimeInspector {
404
405
}
405
406
406
407
/// This function blocks the thread until at least one inspector client has
407
- /// established a websocket connection.
408
+ /// io_session_futures a websocket connection.
408
409
pub fn wait_for_session ( & self ) {
409
410
loop {
410
411
if let Some ( _session) =
@@ -420,15 +421,14 @@ impl JsRuntimeInspector {
420
421
}
421
422
422
423
/// This function blocks the thread until at least one inspector client has
423
- /// established a websocket connection.
424
+ /// io_session_futures a websocket connection.
424
425
///
425
426
/// After that, it instructs V8 to pause at the next statement.
426
427
/// Frontend must send "Runtime.runIfWaitingForDebugger" message to resume
427
428
/// execution.
428
429
pub fn wait_for_session_and_break_on_next_statement ( & self ) {
429
430
loop {
430
- if let Some ( session) =
431
- self . state . sessions . borrow_mut ( ) . local . values ( ) . next ( )
431
+ if let Some ( session) = self . state . sessions . borrow ( ) . local . values ( ) . next ( )
432
432
{
433
433
break session. break_on_next_statement ( ) ;
434
434
} else {
@@ -488,23 +488,28 @@ pub struct SessionsState {
488
488
/// parts of their lifecycle.
489
489
pub struct SessionContainer {
490
490
v8_inspector : Option < Rc < v8:: inspector:: V8Inspector > > ,
491
- session_rx : UnboundedReceiver < NewSessionTxMsg > ,
491
+
492
492
is_dispatching_message : Rc < RefCell < bool > > ,
493
- established : FuturesUnordered < InspectorSessionPumpMessages > ,
493
+
494
+ // These two are purely remote/IO sessions related
495
+ new_io_session_rx : UnboundedReceiver < NewSessionTxMsg > ,
496
+ io_session_futures : FuturesUnordered < InspectorSessionPumpMessages > ,
497
+
498
+ // These two are actually sessions
494
499
next_local_id : i32 ,
495
500
local : HashMap < i32 , Rc < InspectorSession > > ,
496
501
}
497
502
498
503
impl SessionContainer {
499
504
fn new (
500
505
v8_inspector : Rc < v8:: inspector:: V8Inspector > ,
501
- new_session_rx : UnboundedReceiver < NewSessionTxMsg > ,
506
+ new_new_io_session_rx : UnboundedReceiver < NewSessionTxMsg > ,
502
507
is_dispatching_message : Rc < RefCell < bool > > ,
503
508
) -> Self {
504
509
Self {
505
510
v8_inspector : Some ( v8_inspector) ,
506
- session_rx : new_session_rx ,
507
- established : FuturesUnordered :: new ( ) ,
511
+ new_io_session_rx : new_new_io_session_rx ,
512
+ io_session_futures : FuturesUnordered :: new ( ) ,
508
513
next_local_id : 1 ,
509
514
local : HashMap :: new ( ) ,
510
515
is_dispatching_message,
@@ -517,13 +522,13 @@ impl SessionContainer {
517
522
/// all sessions before dropping the inspector instance.
518
523
fn drop_sessions ( & mut self ) {
519
524
self . v8_inspector = Default :: default ( ) ;
520
- self . established . clear ( ) ;
525
+ self . io_session_futures . clear ( ) ;
521
526
self . local . clear ( ) ;
522
527
}
523
528
524
529
fn sessions_state ( & self ) -> SessionsState {
525
530
SessionsState {
526
- has_active : !self . established . is_empty ( ) || !self . local . is_empty ( ) ,
531
+ has_active : !self . io_session_futures . is_empty ( ) || !self . local . is_empty ( ) ,
527
532
has_blocking : self
528
533
. local
529
534
. values ( )
@@ -550,8 +555,8 @@ impl SessionContainer {
550
555
let ( _tx, rx) = mpsc:: unbounded :: < NewSessionTxMsg > ( ) ;
551
556
Self {
552
557
v8_inspector : Default :: default ( ) ,
553
- session_rx : rx,
554
- established : FuturesUnordered :: new ( ) ,
558
+ new_io_session_rx : rx,
559
+ io_session_futures : FuturesUnordered :: new ( ) ,
555
560
next_local_id : 1 ,
556
561
local : HashMap :: new ( ) ,
557
562
is_dispatching_message : Default :: default ( ) ,
@@ -592,23 +597,23 @@ impl SessionContainer {
592
597
fn pump_messages_for_remote_sessions ( & mut self , cx : & mut Context ) {
593
598
loop {
594
599
// Accept new connections.
595
- let poll_result = self . session_rx . poll_next_unpin ( cx) ;
600
+ let poll_result = self . new_io_session_rx . poll_next_unpin ( cx) ;
596
601
if let Poll :: Ready ( Some ( new_session_msg) ) = poll_result {
597
602
let ( callback, rx, kind) = new_session_msg;
598
603
let session = self . create_new_session ( callback, kind) ;
599
604
600
605
let mut fut =
601
606
pump_inspector_session_messages ( session, rx) . boxed_local ( ) ;
602
607
let _ = fut. poll_unpin ( cx) ;
603
- self . established . push ( fut) ;
608
+ self . io_session_futures . push ( fut) ;
604
609
605
- // TODO(bartlomieju): decide on this - should we drain the `session_rx ` queue fully
606
- // before polling `established ` sessions?
610
+ // TODO(bartlomieju): decide on this - should we drain the `new_io_session_rx ` queue fully
611
+ // before polling `io_session_futures ` sessions?
607
612
continue ;
608
613
}
609
614
610
- // Poll established sessions.
611
- match self . established . poll_next_unpin ( cx) {
615
+ // Poll io_session_futures sessions.
616
+ match self . io_session_futures . poll_next_unpin ( cx) {
612
617
Poll :: Ready ( Some ( ( ) ) ) => {
613
618
continue ;
614
619
}
0 commit comments