[Yellowstone] Wireframe for moving yellowstone to rust.
This commit is contained in:
parent
0aa4a1f5f1
commit
c9b484089e
24 changed files with 265 additions and 25 deletions
19
rust/lib/mammoth/src/sync.rs
Normal file
19
rust/lib/mammoth/src/sync.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
use crate::{cap::Capability, syscall, zion::ZError};
|
||||
|
||||
pub struct Semaphore {
|
||||
cap: Capability,
|
||||
}
|
||||
|
||||
impl Semaphore {
|
||||
pub fn new() -> Result<Self, ZError> {
|
||||
syscall::semaphore_create().map(|cap| Self { cap })
|
||||
}
|
||||
|
||||
pub fn wait(&self) -> Result<(), ZError> {
|
||||
syscall::semaphone_wait(&self.cap)
|
||||
}
|
||||
|
||||
pub fn signal(&self) -> Result<(), ZError> {
|
||||
syscall::semaphone_signal(&self.cap)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue