LanguageExt.Core

LanguageExt.Core Concurrency STM

Contents

struct CommuteRef <A> Source #

A proxy for Ref, returned by commute. This allows the transaction system to know that the result is a commutative and therefore give you a result based on the live state rather than the transaction.

See the concurrency section of the wiki for more info.

Properties

property A Value Source #

Methods

method string ToString () Source #

method int GetHashCode () Source #

method bool Equals (object? obj) Source #

method bool Equals (A other) Source #

method A Swap (Func<A, A> f) Source #

method IO<A> SwapIO (Func<A, A> f) Source #

method CommuteRef<A> Commute (Func<A, A> f) Source #

enum Isolation Source #

sync transaction isolation level. Used to enforce ACI properties of ACID on Refs.

See the concurrency section of the wiki for more info.

class Ref <A> Source #

Refs ensure safe shared use of mutable storage locations via a software transactional memory (STM) system. Refs are bound to a single storage location for their lifetime, and only allow mutation of that location to occur within a transaction.

See the concurrency section of the wiki for more info.

Properties

property A Value Source #

Value accessor (read and write)

property IO<A> ValueIO Source #

Value accessor (read and write)

  • Gets will return a freshly constructed IO monad that can be repeatedly evaluated to get the latest state of the Ref.

  • Sets pass an IO monad that will be mapped to an operation that will set the value of the Ref each time it's evaluated.

Methods

method string ToString () Source #

ToString for the bound value

method int GetHashCode () Source #

Hash code of the bound value

method bool Equals (object? obj) Source #

Equality

method bool Equals (A? other) Source #

Equality

method A Swap (Func<A, A> f) Source #

Swap the old value for the new returned by f Must be run within a sync transaction

Parameters

param f

Swap function

returns

The value returned from f

method IO<A> SwapIO (Func<A, A> f) Source #

Swap the old value for the new returned by f Must be run within a sync transaction

Parameters

param f

Swap function

returns

The value returned from f

method CommuteRef<A> Commute (Func<A, A> f) Source #

Must be called in a transaction. Sets the in-transaction-value of ref to:

`f(in-transaction-value-of-ref)`

and returns the in-transaction-value when complete.

At the commit point of the transaction, f is run AGAIN with the most recently committed value:

`f(most-recently-committed-value-of-ref)`

Thus f should be commutative, or, failing that, you must accept last-one-in-wins behavior.

Commute allows for more concurrency than just setting the Ref's value

class STM Source #

Software transactional memory using Multi-Version Concurrency Control (MVCC)

See the concurrency section of the wiki for more info.

Properties

property long TransactionId Source #

Get the currently running TransactionId