Added directfs

Added a very rudimentary file I/O system suitable for experimenting
with the language further. A better one will be designed when we have
sensible error management.
This commit is contained in:
2023-09-17 16:37:39 +01:00
parent 1078835e8b
commit 7396078304
84 changed files with 563 additions and 721 deletions

View File

@@ -223,6 +223,26 @@ impl SeqScheduler {
})
}
/// Run an operation asynchronously and then process its result in thread,
/// without queuing on any particular data.
pub fn run_orphan<T: Send + 'static>(
&self,
operation: impl FnOnce(Canceller) -> T + Send + 'static,
handler: impl FnOnce(T, Canceller) -> Vec<ExprInst> + 'static,
) -> Canceller {
let cancelled = Canceller::new();
let canc1 = cancelled.clone();
let opid = self.0.pending.borrow_mut().insert(Box::new(|data, _| {
handler(*data.downcast().expect("This is associated by ID"), canc1)
}));
let canc1 = cancelled.clone();
let mut port = self.0.port.clone();
self.0.pool.submit(Box::new(move || {
port.send(SyncReply { opid, data: Box::new(operation(canc1)) });
}));
cancelled
}
/// Schedule a function that will consume the value. After this the handle is
/// considered sealed and all [SeqScheduler::schedule] calls will fail.
pub fn seal<T>(