Orbital (#16)
* Port previous ethernet scheme
* Add ipd
* Fix initfs rebuilds, use QEMU user networking addresses in ipd
* Add tcp/udp, netutils, dns, and network config
* Add fsync to network driver
* Add dns, router, subnet by default
* Fix e1000 driver. Make ethernet and IP non-blocking to avoid deadlocks
* Add orbital server, WIP
* Add futex
* Add orbutils and orbital
* Update libstd, orbutils, and orbital
Move ANSI key encoding to vesad
* Add orbital assets
* Update orbital
* Update to add login manager
* Add blocking primitives, block for most things except waitpid, update orbital
* Wait in waitpid and IRQ, improvements for other waits
* Fevent in root scheme
* WIP: Switch to using fevent
* Reorganize
* Event based e1000d driver
* Superuser-only access to some network schemes, display, and disk
* Superuser root and irq schemes
* Fix orbital
2016-10-14 01:21:42 +02:00
|
|
|
use collections::BTreeMap;
|
2016-11-01 18:04:53 +01:00
|
|
|
use core::mem;
|
Orbital (#16)
* Port previous ethernet scheme
* Add ipd
* Fix initfs rebuilds, use QEMU user networking addresses in ipd
* Add tcp/udp, netutils, dns, and network config
* Add fsync to network driver
* Add dns, router, subnet by default
* Fix e1000 driver. Make ethernet and IP non-blocking to avoid deadlocks
* Add orbital server, WIP
* Add futex
* Add orbutils and orbital
* Update libstd, orbutils, and orbital
Move ANSI key encoding to vesad
* Add orbital assets
* Update orbital
* Update to add login manager
* Add blocking primitives, block for most things except waitpid, update orbital
* Wait in waitpid and IRQ, improvements for other waits
* Fevent in root scheme
* WIP: Switch to using fevent
* Reorganize
* Event based e1000d driver
* Superuser-only access to some network schemes, display, and disk
* Superuser root and irq schemes
* Fix orbital
2016-10-14 01:21:42 +02:00
|
|
|
use spin::Mutex;
|
|
|
|
|
|
|
|
use sync::WaitCondition;
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct WaitMap<K, V> {
|
|
|
|
inner: Mutex<BTreeMap<K, V>>,
|
|
|
|
condition: WaitCondition
|
|
|
|
}
|
|
|
|
|
2016-11-01 18:04:53 +01:00
|
|
|
impl<K, V> WaitMap<K, V> where K: Clone + Ord {
|
Orbital (#16)
* Port previous ethernet scheme
* Add ipd
* Fix initfs rebuilds, use QEMU user networking addresses in ipd
* Add tcp/udp, netutils, dns, and network config
* Add fsync to network driver
* Add dns, router, subnet by default
* Fix e1000 driver. Make ethernet and IP non-blocking to avoid deadlocks
* Add orbital server, WIP
* Add futex
* Add orbutils and orbital
* Update libstd, orbutils, and orbital
Move ANSI key encoding to vesad
* Add orbital assets
* Update orbital
* Update to add login manager
* Add blocking primitives, block for most things except waitpid, update orbital
* Wait in waitpid and IRQ, improvements for other waits
* Fevent in root scheme
* WIP: Switch to using fevent
* Reorganize
* Event based e1000d driver
* Superuser-only access to some network schemes, display, and disk
* Superuser root and irq schemes
* Fix orbital
2016-10-14 01:21:42 +02:00
|
|
|
pub fn new() -> WaitMap<K, V> {
|
|
|
|
WaitMap {
|
|
|
|
inner: Mutex::new(BTreeMap::new()),
|
|
|
|
condition: WaitCondition::new()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-01 18:04:53 +01:00
|
|
|
pub fn receive_nonblock(&self, key: &K) -> Option<V> {
|
|
|
|
self.inner.lock().remove(key)
|
Orbital (#16)
* Port previous ethernet scheme
* Add ipd
* Fix initfs rebuilds, use QEMU user networking addresses in ipd
* Add tcp/udp, netutils, dns, and network config
* Add fsync to network driver
* Add dns, router, subnet by default
* Fix e1000 driver. Make ethernet and IP non-blocking to avoid deadlocks
* Add orbital server, WIP
* Add futex
* Add orbutils and orbital
* Update libstd, orbutils, and orbital
Move ANSI key encoding to vesad
* Add orbital assets
* Update orbital
* Update to add login manager
* Add blocking primitives, block for most things except waitpid, update orbital
* Wait in waitpid and IRQ, improvements for other waits
* Fevent in root scheme
* WIP: Switch to using fevent
* Reorganize
* Event based e1000d driver
* Superuser-only access to some network schemes, display, and disk
* Superuser root and irq schemes
* Fix orbital
2016-10-14 01:21:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn receive(&self, key: &K) -> V {
|
|
|
|
loop {
|
2016-11-01 18:04:53 +01:00
|
|
|
if let Some(value) = self.receive_nonblock(key) {
|
Orbital (#16)
* Port previous ethernet scheme
* Add ipd
* Fix initfs rebuilds, use QEMU user networking addresses in ipd
* Add tcp/udp, netutils, dns, and network config
* Add fsync to network driver
* Add dns, router, subnet by default
* Fix e1000 driver. Make ethernet and IP non-blocking to avoid deadlocks
* Add orbital server, WIP
* Add futex
* Add orbutils and orbital
* Update libstd, orbutils, and orbital
Move ANSI key encoding to vesad
* Add orbital assets
* Update orbital
* Update to add login manager
* Add blocking primitives, block for most things except waitpid, update orbital
* Wait in waitpid and IRQ, improvements for other waits
* Fevent in root scheme
* WIP: Switch to using fevent
* Reorganize
* Event based e1000d driver
* Superuser-only access to some network schemes, display, and disk
* Superuser root and irq schemes
* Fix orbital
2016-10-14 01:21:42 +02:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
self.condition.wait();
|
|
|
|
}
|
|
|
|
}
|
2016-11-01 18:04:53 +01:00
|
|
|
|
|
|
|
pub fn receive_any_nonblock(&self) -> Option<(K, V)> {
|
|
|
|
let mut inner = self.inner.lock();
|
|
|
|
if let Some(key) = inner.keys().next().map(|key| key.clone()) {
|
|
|
|
inner.remove(&key).map(|value| (key, value))
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn receive_any(&self) -> (K, V) {
|
|
|
|
loop {
|
|
|
|
if let Some(entry) = self.receive_any_nonblock() {
|
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
self.condition.wait();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn receive_all(&self) -> BTreeMap<K, V> {
|
|
|
|
let mut ret = BTreeMap::new();
|
|
|
|
mem::swap(&mut ret, &mut *self.inner.lock());
|
|
|
|
ret
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn send(&self, key: K, value: V) {
|
|
|
|
self.inner.lock().insert(key, value);
|
|
|
|
self.condition.notify();
|
|
|
|
}
|
Orbital (#16)
* Port previous ethernet scheme
* Add ipd
* Fix initfs rebuilds, use QEMU user networking addresses in ipd
* Add tcp/udp, netutils, dns, and network config
* Add fsync to network driver
* Add dns, router, subnet by default
* Fix e1000 driver. Make ethernet and IP non-blocking to avoid deadlocks
* Add orbital server, WIP
* Add futex
* Add orbutils and orbital
* Update libstd, orbutils, and orbital
Move ANSI key encoding to vesad
* Add orbital assets
* Update orbital
* Update to add login manager
* Add blocking primitives, block for most things except waitpid, update orbital
* Wait in waitpid and IRQ, improvements for other waits
* Fevent in root scheme
* WIP: Switch to using fevent
* Reorganize
* Event based e1000d driver
* Superuser-only access to some network schemes, display, and disk
* Superuser root and irq schemes
* Fix orbital
2016-10-14 01:21:42 +02:00
|
|
|
}
|