Skip to content

Commit 36802e9

Browse files
committed
Remove the host writer from the arguments to UninitializedSandbox::new
Signed-off-by: Jorge Prendes <[email protected]>
1 parent d3a7498 commit 36802e9

File tree

23 files changed

+193
-198
lines changed

23 files changed

+193
-198
lines changed

src/hyperlight_host/benches/benchmarks.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use hyperlight_testing::simple_guest_as_string;
2626

2727
fn create_uninit_sandbox() -> UninitializedSandbox {
2828
let path = simple_guest_as_string().unwrap();
29-
UninitializedSandbox::new(GuestBinary::FilePath(path), None, None, None).unwrap()
29+
UninitializedSandbox::new(GuestBinary::FilePath(path), None, None).unwrap()
3030
}
3131

3232
fn create_multiuse_sandbox() -> MultiUseSandbox {
@@ -83,7 +83,6 @@ fn guest_call_benchmark(c: &mut Criterion) {
8383
GuestBinary::FilePath(simple_guest_as_string().unwrap()),
8484
Some(config),
8585
None,
86-
None,
8786
)
8887
.unwrap();
8988
let mut sandbox = sandbox.evolve(Noop::default()).unwrap();

src/hyperlight_host/examples/func_ctx/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ fn main() {
2727
// test guest binary
2828
let sbox1: MultiUseSandbox = {
2929
let path = simple_guest_as_string().unwrap();
30-
let u_sbox =
31-
UninitializedSandbox::new(GuestBinary::FilePath(path), None, None, None).unwrap();
30+
let u_sbox = UninitializedSandbox::new(GuestBinary::FilePath(path), None, None).unwrap();
3231
u_sbox.evolve(Noop::default())
3332
}
3433
.unwrap();

src/hyperlight_host/examples/guest-debugging/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ fn main() -> hyperlight_host::Result<()> {
4949
),
5050
cfg, // sandbox configuration
5151
None, // default run options
52-
None, // default host print function
5352
)?;
5453

5554
// Register a host functions

src/hyperlight_host/examples/hello-world/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ fn main() -> hyperlight_host::Result<()> {
2929
),
3030
None, // default configuration
3131
None, // default run options
32-
None, // default host print function
3332
)?;
3433

3534
// Register a host functions

src/hyperlight_host/examples/logging/main.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ limitations under the License.
1515
*/
1616

1717
extern crate hyperlight_host;
18-
use std::sync::{Arc, Mutex};
1918

2019
use hyperlight_common::flatbuffer_wrappers::function_types::{ParameterValue, ReturnType};
2120
use hyperlight_host::sandbox::uninitialized::UninitializedSandbox;
@@ -41,15 +40,10 @@ fn main() -> Result<()> {
4140

4241
for _ in 0..20 {
4342
let path = hyperlight_guest_path.clone();
44-
let writer_func = Arc::new(Mutex::new(fn_writer));
4543
let res: Result<()> = {
4644
// Create a new sandbox.
47-
let usandbox = UninitializedSandbox::new(
48-
GuestBinary::FilePath(path),
49-
None,
50-
None,
51-
Some(&writer_func),
52-
)?;
45+
let mut usandbox = UninitializedSandbox::new(GuestBinary::FilePath(path), None, None)?;
46+
usandbox.register_print(fn_writer)?;
5347

5448
// Initialize the sandbox.
5549

@@ -91,7 +85,6 @@ fn main() -> Result<()> {
9185
GuestBinary::FilePath(hyperlight_guest_path.clone()),
9286
None,
9387
None,
94-
None,
9588
)?;
9689

9790
// Initialize the sandbox.

src/hyperlight_host/examples/metrics/main.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ limitations under the License.
1515
*/
1616

1717
extern crate hyperlight_host;
18-
use std::sync::{Arc, Mutex};
1918
use std::thread::{spawn, JoinHandle};
2019

2120
use hyperlight_common::flatbuffer_wrappers::function_types::{ParameterValue, ReturnType};
@@ -53,15 +52,10 @@ fn do_hyperlight_stuff() {
5352

5453
for _ in 0..20 {
5554
let path = hyperlight_guest_path.clone();
56-
let writer_func = Arc::new(Mutex::new(fn_writer));
5755
let handle = spawn(move || -> Result<()> {
5856
// Create a new sandbox.
59-
let usandbox = UninitializedSandbox::new(
60-
GuestBinary::FilePath(path),
61-
None,
62-
None,
63-
Some(&writer_func),
64-
)?;
57+
let mut usandbox = UninitializedSandbox::new(GuestBinary::FilePath(path), None, None)?;
58+
usandbox.register_print(fn_writer)?;
6559

6660
// Initialize the sandbox.
6761

@@ -103,7 +97,6 @@ fn do_hyperlight_stuff() {
10397
GuestBinary::FilePath(hyperlight_guest_path.clone()),
10498
None,
10599
None,
106-
None,
107100
)
108101
.expect("Failed to create UninitializedSandbox");
109102

src/hyperlight_host/examples/tracing-chrome/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ fn main() -> Result<()> {
3333
simple_guest_as_string().expect("Cannot find the guest binary at the expected location.");
3434

3535
// Create a new sandbox.
36-
let usandbox =
37-
UninitializedSandbox::new(GuestBinary::FilePath(simple_guest_path), None, None, None)?;
36+
let usandbox = UninitializedSandbox::new(GuestBinary::FilePath(simple_guest_path), None, None)?;
3837

3938
let mut sbox = usandbox
4039
.evolve(Noop::<UninitializedSandbox, MultiUseSandbox>::default())

src/hyperlight_host/examples/tracing-otlp/main.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ fn run_example(wait_input: bool) -> HyperlightResult<()> {
116116
for i in 0..10 {
117117
let path = hyperlight_guest_path.clone();
118118
let exit = Arc::clone(&should_exit);
119-
let writer_func = Arc::new(Mutex::new(fn_writer));
120119
let handle = spawn(move || -> HyperlightResult<()> {
121120
while !*exit.try_lock().unwrap() {
122121
// Construct a new span named "hyperlight tracing example thread" with INFO level.
@@ -130,12 +129,9 @@ fn run_example(wait_input: bool) -> HyperlightResult<()> {
130129
let _entered = span.enter();
131130

132131
// Create a new sandbox.
133-
let usandbox = UninitializedSandbox::new(
134-
GuestBinary::FilePath(path.clone()),
135-
None,
136-
None,
137-
Some(&writer_func),
138-
)?;
132+
let mut usandbox =
133+
UninitializedSandbox::new(GuestBinary::FilePath(path.clone()), None, None)?;
134+
usandbox.register_print(fn_writer)?;
139135

140136
// Initialize the sandbox.
141137

src/hyperlight_host/examples/tracing-tracy/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ fn main() -> Result<()> {
3939
simple_guest_as_string().expect("Cannot find the guest binary at the expected location.");
4040

4141
// Create a new sandbox.
42-
let usandbox =
43-
UninitializedSandbox::new(GuestBinary::FilePath(simple_guest_path), None, None, None)?;
42+
let usandbox = UninitializedSandbox::new(GuestBinary::FilePath(simple_guest_path), None, None)?;
4443

4544
let mut sbox = usandbox
4645
.evolve(Noop::<UninitializedSandbox, MultiUseSandbox>::default())

src/hyperlight_host/examples/tracing/main.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ limitations under the License.
1717
use hyperlight_common::flatbuffer_wrappers::function_types::{ParameterValue, ReturnType};
1818
use tracing::{span, Level};
1919
extern crate hyperlight_host;
20-
use std::sync::{Arc, Mutex};
2120
use std::thread::{spawn, JoinHandle};
2221

2322
use hyperlight_host::sandbox::uninitialized::UninitializedSandbox;
@@ -60,7 +59,6 @@ fn run_example() -> Result<()> {
6059

6160
for i in 0..10 {
6261
let path = hyperlight_guest_path.clone();
63-
let writer_func = Arc::new(Mutex::new(fn_writer));
6462
let handle = spawn(move || -> Result<()> {
6563
// Construct a new span named "hyperlight tracing example thread" with INFO level.
6664
let id = Uuid::new_v4();
@@ -73,12 +71,8 @@ fn run_example() -> Result<()> {
7371
let _entered = span.enter();
7472

7573
// Create a new sandbox.
76-
let usandbox = UninitializedSandbox::new(
77-
GuestBinary::FilePath(path),
78-
None,
79-
None,
80-
Some(&writer_func),
81-
)?;
74+
let mut usandbox = UninitializedSandbox::new(GuestBinary::FilePath(path), None, None)?;
75+
usandbox.register_print(fn_writer)?;
8276

8377
// Initialize the sandbox.
8478

@@ -119,7 +113,6 @@ fn run_example() -> Result<()> {
119113
GuestBinary::FilePath(hyperlight_guest_path.clone()),
120114
None,
121115
None,
122-
None,
123116
)?;
124117

125118
// Initialize the sandbox.

0 commit comments

Comments
 (0)