Now with Atomicity

This commit is contained in:
2018-05-23 20:35:16 +02:00
parent 9f7f9598db
commit 1384971d4e
5 changed files with 12 additions and 17 deletions

View File

@@ -1,6 +1,5 @@
use std::io::{Read, Write};
use std::sync::Mutex;
use std::rc::Rc;
use std::sync::{Mutex, Arc};
use Result;
use block::Block;
@@ -32,7 +31,7 @@ pub struct Machine {
pub heap: Heap,
pub stream_in: Box<Read + Send + Sync>,
pub stream_out: Rc<Mutex<Write + Send + Sync>>,
pub stream_out: Arc<Mutex<Write + Send + Sync>>,
}
@@ -45,7 +44,7 @@ impl Machine {
block,
frame: vec![Frame::new(ANTI_BS_SIZE)],
stream_in: Box::new(::std::io::stdin()),
stream_out: Rc::new(Mutex::new(::std::io::stdout())),
stream_out: Arc::new(Mutex::new(::std::io::stdout())),
#[cfg(feature = "bonus:network")]
net: NetStack::new(),
@@ -152,7 +151,7 @@ impl Machine {
self.stream_in = instream;
}
pub fn set_output(&mut self, outstream: Rc<Mutex<Write + Send + Sync>>) {
pub fn set_output(&mut self, outstream: Arc<Mutex<Write + Send + Sync>>) {
self.stream_out = outstream;
}
}