@@ -47,15 +47,6 @@ impl MultiUseGuestCallContext {
4747 pub fn start ( sbox : MultiUseSandbox ) -> Self {
4848 Self { sbox }
4949 }
50-
51- /// Close out the context and get back the internally-stored
52- /// `MultiUseSandbox`. Future contexts opened by the returned sandbox
53- /// will have guest state restored.
54- #[ instrument( err( Debug ) , skip( self ) , parent = Span :: current( ) ) ]
55- pub fn finish ( mut self ) -> Result < MultiUseSandbox > {
56- self . sbox . restore_state ( ) ?;
57- Ok ( self . sbox )
58- }
5950}
6051
6152impl Callable for MultiUseGuestCallContext {
@@ -96,8 +87,6 @@ mod tests {
9687
9788 use hyperlight_testing:: simple_guest_as_string;
9889
99- use super :: MultiUseGuestCallContext ;
100- use crate :: sandbox:: Callable ;
10190 use crate :: sandbox_state:: sandbox:: EvolvableSandbox ;
10291 use crate :: sandbox_state:: transition:: Noop ;
10392 use crate :: { GuestBinary , HyperlightError , MultiUseSandbox , Result , UninitializedSandbox } ;
@@ -134,12 +123,12 @@ mod tests {
134123 // requests to execute batches of calls
135124 let recv_hdl = thread:: spawn ( move || {
136125 let mut sbox: MultiUseSandbox = new_uninit ( ) . unwrap ( ) . evolve ( Noop :: default ( ) ) . unwrap ( ) ;
126+ let snapshot = sbox. snapshot ( ) . unwrap ( ) ;
137127 while let Ok ( calls) = recv. recv ( ) {
138- let mut ctx = sbox. new_call_context ( ) ;
139128 for call in calls {
140- call. call ( & mut ctx ) ;
129+ call. call ( & mut sbox ) ;
141130 }
142- sbox = ctx . finish ( ) . unwrap ( ) ;
131+ sbox. restore ( & snapshot ) . unwrap ( ) ;
143132 }
144133 } ) ;
145134
@@ -151,11 +140,15 @@ mod tests {
151140 let calls = vec ! [
152141 TestFuncCall :: new( move |ctx| {
153142 let msg = format!( "Hello {}" , i) ;
154- let ret: String = ctx. call( "Echo" , msg. clone( ) ) . unwrap( ) ;
143+ let ret: String = ctx
144+ . call_guest_function_by_name( "Echo" , msg. clone( ) )
145+ . unwrap( ) ;
155146 assert_eq!( ret, msg)
156147 } ) ,
157148 TestFuncCall :: new( move |ctx| {
158- let ret: i32 = ctx. call( "CallMalloc" , i + 2 ) . unwrap( ) ;
149+ let ret: i32 = ctx
150+ . call_guest_function_by_name( "CallMalloc" , i + 2 )
151+ . unwrap( ) ;
159152 assert_eq!( ret, i + 2 )
160153 } ) ,
161154 ] ;
@@ -187,7 +180,9 @@ mod tests {
187180 let snapshot = self . sandbox . snapshot ( ) ?;
188181 let mut sum: i32 = 0 ;
189182 for n in 0 ..i {
190- let result = self . sandbox . call_guest_function_by_name :: < i32 > ( "AddToStatic" , n) ;
183+ let result = self
184+ . sandbox
185+ . call_guest_function_by_name :: < i32 > ( "AddToStatic" , n) ;
191186 sum += n;
192187 println ! ( "{:?}" , result) ;
193188 let result = result. unwrap ( ) ;
@@ -226,14 +221,14 @@ mod tests {
226221 assert ! ( result. is_ok( ) ) ;
227222 }
228223
229- struct TestFuncCall ( Box < dyn FnOnce ( & mut MultiUseGuestCallContext ) + Send > ) ;
224+ struct TestFuncCall ( Box < dyn FnOnce ( & mut MultiUseSandbox ) + Send > ) ;
230225
231226 impl TestFuncCall {
232- fn new ( f : impl FnOnce ( & mut MultiUseGuestCallContext ) + Send + ' static ) -> Self {
227+ fn new ( f : impl FnOnce ( & mut MultiUseSandbox ) + Send + ' static ) -> Self {
233228 TestFuncCall ( Box :: new ( f) )
234229 }
235230
236- fn call ( self , ctx : & mut MultiUseGuestCallContext ) {
231+ fn call ( self , ctx : & mut MultiUseSandbox ) {
237232 ( self . 0 ) ( ctx) ;
238233 }
239234 }
0 commit comments