[][src]Struct pgx::lwlock::PgLwLock

pub struct PgLwLock<T> { /* fields omitted */ }

A Rust locking mechanism which uses a PostgreSQL LWLock to lock the data

This type of lock allows a number of readers or at most one writer at any point in time. The write portion of this lock typically allows modification of the underlying data (exclusive access) and the read portion of this lock typically allows for read-only access (shared access).

The lock is valid across processes as the LWLock is managed by Postgres. Data mutability once a lock is obtained is handled by Rust giving out & or &mut pointers.

When a lock is given out it is wrapped in a PgLwLockShareGuard or PgLwLockExclusiveGuard, which releases the lock on drop

Poisoning

This lock can not be poisoned from Rust. Panic and Abort are handled by PostgreSQL cleanly.

Implementations

impl<T> PgLwLock<T>[src]

pub const fn new() -> Self[src]

Create an empty lock which can be created as a global with None as a sentinel value

pub fn from_named(input_name: &'static str, value: *mut T) -> Self[src]

Create a new lock for T by attaching a LWLock, which is looked up by name

pub fn get_name(&self) -> &'static str[src]

Get the name of the PgLwLock

pub fn share(&self) -> PgLwLockShareGuard<'_, T>[src]

Obtain a shared lock (which comes with &T access)

pub fn exclusive(&self) -> PgLwLockExclusiveGuard<'_, T>[src]

Obtain an exclusive lock (which comes with &mut T access)

pub fn attach(&self, value: *mut T)[src]

Attach an empty PgLwLock lock to a LWLock, and wrap T

Trait Implementations

impl<T> PgSharedMemoryInitialization for PgLwLock<T> where
    T: Default + PGXSharedMemory + 'static, 
[src]

impl<T> Send for PgLwLock<T>[src]

impl<T> Sync for PgLwLock<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for PgLwLock<T> where
    T: RefUnwindSafe

impl<T> Unpin for PgLwLock<T>

impl<T> UnwindSafe for PgLwLock<T> where
    T: RefUnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,