# DisposableLock

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/utilities/struct-disposablelock/

**struct** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
struct DisposableLock
```

A lock whose holder gets a disposable that releases it.

The thread that holds the lock may take it again (the lock of the
reference is a monitor); each disposable releases one entry, on the
thread that took it.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/disposable_lock.rs#L13)

## Members

- [`new`](#function-new)
- [`try_lock`](#function-try_lock)
- [`lock`](#function-lock)

<a id="function-new"></a>

### new

```rust
fn new() -> Self
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/disposable_lock.rs#L56)

<a id="function-try_lock"></a>

### try_lock

```rust
fn try_lock(self: &Self) -> Option<Rc<dyn IDisposable>>
```

Tries to take the lock. Returns the disposable that releases it if
the lock was obtained.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/disposable_lock.rs#L62)

<a id="function-lock"></a>

### lock

```rust
fn lock(self: &Self) -> Rc<dyn IDisposable>
```

Enters a waiting lock.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/disposable_lock.rs#L67)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- `ErasedDestructor`
- `IntoEither`
- `Clone`
- `Default`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
