@@ -3,10 +3,7 @@ use std::{
33 borrow:: BorrowMut ,
44 cell:: RefCell ,
55 collections:: VecDeque ,
6- sync:: {
7- atomic:: Ordering ,
8- mpsc:: { Receiver , Sender } ,
9- } ,
6+ sync:: { atomic:: Ordering , mpsc:: Receiver } ,
107} ;
118
129use nova_vm:: {
@@ -82,12 +79,7 @@ pub struct RuntimeConfig<UserMacroTask: 'static> {
8279 pub builtins : Vec < & ' static str > ,
8380 /// User event loop handler.
8481 pub eventloop_handler : EventLoopHandler < UserMacroTask > ,
85- }
86-
87- pub struct RuntimeData < UserMacroTask : ' static > {
88- /// Macro tasks sender.
89- pub macro_task_tx : Sender < MacroTask < UserMacroTask > > ,
90- /// Macro tasks receiver.
82+ /// Macro tasks eventloop receiver.
9183 pub macro_task_rx : Receiver < MacroTask < UserMacroTask > > ,
9284}
9385
@@ -96,13 +88,14 @@ pub struct Runtime<UserMacroTask: 'static> {
9688 pub agent : GcAgent ,
9789 pub realm_root : RealmRoot ,
9890 pub host_hooks : & ' static RuntimeHostHooks < UserMacroTask > ,
99- pub macro_task_rx : Receiver < MacroTask < UserMacroTask > > ,
10091}
10192
10293impl < UserMacroTask > Runtime < UserMacroTask > {
10394 /// Create a new [Runtime] given a [RuntimeConfig]. Use [Runtime::run] to run it.
104- pub fn new ( mut config : RuntimeConfig < UserMacroTask > , data : RuntimeData < UserMacroTask > ) -> Self {
105- let host_data = HostData :: new ( data. macro_task_tx ) ;
95+ pub fn new (
96+ mut config : RuntimeConfig < UserMacroTask > ,
97+ host_data : HostData < UserMacroTask > ,
98+ ) -> Self {
10699 let host_hooks = RuntimeHostHooks :: new ( host_data) ;
107100
108101 let host_hooks: & RuntimeHostHooks < UserMacroTask > = & * Box :: leak ( Box :: new ( host_hooks) ) ;
@@ -135,7 +128,6 @@ impl<UserMacroTask> Runtime<UserMacroTask> {
135128 agent,
136129 realm_root,
137130 host_hooks,
138- macro_task_rx : data. macro_task_rx ,
139131 }
140132 }
141133
@@ -214,7 +206,7 @@ impl<UserMacroTask> Runtime<UserMacroTask> {
214206
215207 // Listen for pending macro tasks and resolve one by one
216208 pub fn handle_macro_task ( & mut self ) {
217- match self . macro_task_rx . recv ( ) {
209+ match self . config . macro_task_rx . recv ( ) {
218210 Ok ( MacroTask :: ResolvePromise ( root_value) ) => {
219211 self . agent . run_in_realm ( & self . realm_root , |agent, gc| {
220212 let value = root_value. take ( agent) ;
0 commit comments