cogciprocate / qutex Goto Github PK
View Code? Open in Web Editor NEWSynchronization mechanisms based on lock-free queues and Rust futures
License: MIT License
Synchronization mechanisms based on lock-free queues and Rust futures
License: MIT License
Line 34 in dac4838
impl<T: Default> Default for Qutex<T> {
fn default() -> Self {
Self::new(T::default())
}
}
// and QrwLock
The implementation of Guard::unlock
actually leaves the lock still locked by canceling the Drop
implementation for Guard
. I believe a call to qutex.direct_unlock()
is needed after the mem::forget
for the function to work as intended.
Canceled
error in custom error type?Here's example code which causes deadlock without unsafe code.
extern crate futures;
extern crate qutex;
use qutex::*;
use futures::prelude::*;
fn main() {
let lock = QrwLock::from(0i32);
let f = lock.clone().write().and_then(move |mut guard_w| {
eprintln!("write lock acquired");
lock.read().and_then(move |guard_r| {
eprintln!("read lock acquired");
let r0 = *guard_r;
*guard_w += 1;
let r1 = *guard_r;
assert_eq!(r0, r1);
Ok(())
})
});
assert_eq!(Ok(()), f.wait());
}
Is there any way to detect the deadlock? It would be nice for FutureGuard
to return Deadlocked
error (just like Canceled
error) if there's any prior FutureGuard
which belongs to current task. In that case, above example will return Error(Deadlocked)
on f.wait()
instead of hanging on deadlock.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.