Skip to content

Lock Guard Drop for tokio-comp #30

Closed
@theBeardA

Description

@theBeardA

I was implementing my own lock manager when i came across this library. since my code base is based on tokio and I dont want to bring in async-std, I was wondering if Drop implementation for the tokio-comp feature using conditional compile is the way to go? I might be missing something, but from my initial experiments, this approach appears to work for Drop.​

#[cfg(feature = "tokio-comp")]
impl Drop for LockGuard {
    fn drop(&mut self) {
        let lock = self.lock.clone();
        let lock_manager = self.lock.lock_manager.clone();
        tokio::spawn(async move {
            let _ = lock_manager.unlock(&lock).await;
        });
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions