Stateful objects. References, mutation, cloning, etc.

IAdjustable

Available since version 1.0 (view source)

PROTOCOL with method -adjust!

A state protocol for references which can mutate parts of their state.

See also: adjustable?, adjust!, reset!

-adjust!

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (-adjust! this key val)

Type signature:
  • (Any ⨯ Any ⨯ Any) → IAdjustable

Adjusts part of the state identified by a key to a given val and returns this. Throws if key does not corresponds to any part of the state, or the particular part cannot be adjusted.

See also: IAdjustable

IAtomic

Available since version 1.0 (view source)

PROTOCOL with method -cas!

A state protocol for atomic value references.

See also: atomic?, mutable?, cas!

-cas!

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (-cas! this oldval newval)

Type signature:
  • (Any ⨯ Any ⨯ Any) → Boolean+

Sets the value to newval if and only if the current value is identical to oldval. Returns true if set happened, otherwse returns false.

See also: IAtomic

IBlockingReference

Available since version 1.0 (view source)

not referred automatically

PROTOCOL with method -deref-for

A state protocol for blocking references.

-deref-for

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (-deref-for this timeout-ms timeout-val)

Type signature:
  • (Any ⨯ Integer+ ⨯ Any) → Any

Returns referenced object or timeout-val, if timeout-ms is reached. Blocks until value is produced or until timeout is reached.

See also: IBlockingReference

ICancellable

Available since version 1.0 (view source)

not referred automatically

PROTOCOL with method -cancel!

An auxiliary state protocol for cancellable objects.

-cancel!

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (-cancel! this)

Type signature:
  • (Any) → Boolean+

Attempts to cancel this, returning true if cancellation was successfull, otherwise returns false. Must not block.

See also: ICancellable

ICancelledAware

Available since version 1.0 (view source)

not referred automatically

PROTOCOL with method -cancelled?

An auxiliary state protocol for objects which can be cancelled.

-cancelled?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (-cancelled? this)

Type signature:
  • (Any) → Boolean+

Returns true if this is already cancelled, otherwise returns false.

See also: ICancelledAware

ICloneable

Available since version 1.0 (view source)

not referred automatically

PROTOCOL with method -clone

An auxiliaty state protocol for cloneable objects.

See also: clone

-clone

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (-clone this)

Type signature:
  • (Any) → ICloneable

Returns a cloned this.

See also: ICloneable

IMutable

Available since version 1.0 (view source)

PROTOCOL with method -reset!

A state protocol for mutable references.

See also: mutable?, reset!

-reset!

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (-reset! this val)

Type signature:
  • (Any ⨯ Any) → Any

Resets the referenced value to val. Returns new value. Mutates this.

See also: IMutable

IOpenAware

Available since version 1.0 (view source)

PROTOCOL with method -open?

An auxiliary state protocol for objects which can be 'open'. Note that there is no IOpenable protocol, see dunaj.resource on how 'opening' of references is handled in Dunaj.

-open?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (-open? this)

Type signature:
  • (Any) → Boolean+

Returns true if this is open, otherwise returns false.

See also: IOpenAware

IPending

Available since version 1.0 (view source)

PROTOCOL with method -realized?

An auxiliary state protocol for objects with pending value.

See also: pending?, realized?

-realized?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (-realized? this)

Type signature:
  • (Any) → Boolean+

Returns true when object’s value has already been realized.

See also: IPending

IReference

Available since version 1.0 (view source)

PROTOCOL with method -deref

A state protocol for reference objects (references).

-deref

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (-deref this)

Type signature:
  • (Any) → Any

Returns the referenced object. Blocks if this also satisfies IBlockingReference.

See also: IReference