Logo Mibo

ChangeableSet<'T> Type

A changeable set: the writable source of an adaptive set. Reads and writes are confined to the owner thread.

Writes inside a Transaction.run are journaled in order and applied at commit as one net delta: adds and removes of the same element in one batch cancel, and the last write wins. Reads inside a transaction see the pre-transaction state.

GetValue returns a transient view of the internal state, valid only until the next write. CSet.force materializes an immutable snapshot.

Constructors

Constructor Description

ChangeableSet(initial)

Full Usage: ChangeableSet(initial)

Parameters:
    initial : 'T seq

Returns: ChangeableSet<'T>
initial : 'T seq
Returns: ChangeableSet<'T>

Instance members

Instance member Description

this.Add

Full Usage: this.Add

Parameters:
    item : 'T

Adds an element. No-op when already present.

item : 'T

this.PostAdd

Full Usage: this.PostAdd

Parameters:
    item : 'T

Posts an add. Safe from any thread: the operation is queued and returns immediately. The owner thread applies the queued operations at the next graph operation (reads and writes auto-drain) or at Posting.pump, as one batch: one net delta, one notification delivery, and a burst is coalesced into a single handoff.

item : 'T
Example

 // worker thread
 CSet.postAdd item items
 // owner thread: the next read applies the post automatically
 let view = ASet.force items
val view: obj

this.PostRemove

Full Usage: this.PostRemove

Parameters:
    item : 'T

Posts a remove. Safe from any thread. See PostAdd for the application contract.

item : 'T
Example

 // worker thread
 CSet.postRemove item items

this.PostSet

Full Usage: this.PostSet

Parameters:
    newValue : 'T seq

Posts a full replace. Safe from any thread. See PostAdd for the application contract; a posted replace supersedes the other ops of the same pending batch (the transaction semantics of Set).

newValue : 'T seq
Example

 // worker thread
 CSet.postSet (Set.ofList [ 1; 2; 3 ]) items
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool member IsProperSubsetOf: otherSet: Set<'T> -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val ofList: elements: 'T list -> Set<'T> (requires comparison)

this.Remove

Full Usage: this.Remove

Parameters:
    item : 'T

Removes an element. No-op when absent.

item : 'T

this.Set

Full Usage: this.Set

Parameters:
    newValue : 'T seq

Replaces the whole set. Supersedes the whole batch inside a
 transaction (later writes of the batch are discarded; matches the
 list, docs/ALIST-DESIGN.md ยง3.3).
newValue : 'T seq

Type something to start searching.