# ThreadSafeObjectPool

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/threading/struct-threadsafeobjectpool/

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

```rust
struct ThreadSafeObjectPool<T>
```

A pool of reusable objects that can be shared between threads.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/threading/thread_safe_object_pool.rs#L6)

## Members

- [`new`](#function-new)
- [`get`](#function-get)
- [`return_and_set_null`](#function-return_and_set_null)
- [`default_pool`](#function-default_pool)

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

### new

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/threading/thread_safe_object_pool.rs#L17)

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

### get

```rust
fn get(self: &Self) -> T
```

Takes an object out of the pool, creating one when the pool is empty.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/threading/thread_safe_object_pool.rs#L22)

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

### return_and_set_null

```rust
fn return_and_set_null(self: &Self, obj: &mut Option<T>)
```

Puts the object back into the pool and clears the slot it came from.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/threading/thread_safe_object_pool.rs#L28)

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

### default_pool

```rust
fn default_pool() -> Arc<ThreadSafeObjectPool<T>>
```

The process-wide pool for `T`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/threading/thread_safe_object_pool.rs#L40)

## Trait implementations

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

## Availability

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