Common Lisp Package: BACKPORTS

README:

FUNCTION

Public

ABORT-TRANSACTION

Signal a non-recoverable transaction error.

ACQUIRE-READ-LOCK (RWLOCK &OPTIONAL (WAIT-P T))

Lock for reading.

ACQUIRE-WRITE-LOCK (RWLOCK &OPTIONAL (WAIT-P T))

Lock for writing.

ADD-WATCH (REF KEY FN &KEY ONE-SHOT)

Add a watch function. KEY must be unique (via EQUAL), so this will replace any existing function with the same KEY.

AGENT (&OPTIONAL VALUE VALIDATOR)

Function for creating an AGENT from a VALUE.

ALTER (REF F &REST ARGS)

Apply F to the value of REF within a transaction.

ATOMIC (&OPTIONAL VALUE VALIDATOR)

Function for creating an ATOMIC from a VALUE.

ATOMIC-ADJOINF (ATOM &REST ARGS)

ADJOIN an item to the list held by ATOM. Accepts :KEY, :TEST, and :TEST-NOT arguments.

ATOMIC-REMOVEF (ATOM &REST ARGS)

REMOVE an item from the sequence held by ATOM. Accepts :FROM-END, :TEST, :TEST-NOT, :START, :END, :COUNT, and :KEY.

ATOMIC-UNIONF (ATOM &REST ARGS)

Atomically sets the value of ATOM to the UNION of the previous value and the provided list. Accepts :KEY, :TEST, and :TEST-NOT.

COMMUTE (REF F &REST ARGS)

Allows for greater concurrency by discarding any previously read value.

COMPARE-AND-SET! (ATOM OLDVAL NEWVAL)

Atomically set a new value for an atom.

DELIVER (PROMISE VALUE)

Sets the VALUE of a PROMISE, once-only.

ENSURE (REF)

Discard any changes to REF.

FLIP (FN)

Return a function that swaps the order of the first two arguments to FN.

FUTURE-CALL (FN)

Execute a function in a new thread, returning a PROMISE that may, eventally, hold the result.

HAMT-GET (HAMT KEY)

Lookup a value in a hash table. Returns success in a second value.

HAMT-INSERT (HAMT KEY VALUE)

Add a value to a persistent hash table, returning a new table with shared structure.

HAMT-KEYS (HAMT)

Return a list of all the keys of HAMT.

HAMT-REMOVE (HAMT KEY)

Remove a value, returning an new instance of the hash table with shared structure.

IN-TRANSACTION-P

T only if in the context of a transaction.

MAKE-AGENT (&REST ARGS)

Shorthand for instantiating an object and wrapping it in an AGENT.

MAKE-ATOMIC (&REST ARGS)

Shorthand for instantiating an object and wrapping it in an ATOMIC.

MAKE-HAMT (&OPTIONAL (TEST 'EQL))

Return a new persistent hash table.

PROMISE

Returns a new, empty, PROMISE object.

REF (VALUE &OPTIONAL VALIDATOR)

REFs support coordinated, synchronous changes of multiple locations.

REF-SET (REF NEWVAL)

Set the value of REF to NEWVAL within a transaction.

RELEASE-READ-LOCK (RWLOCK)

Unlock after reading.

RELEASE-WRITE-LOCK (RWLOCK)

Unlock after writing.

REMOVE-WATCH (REF KEY)

Remove the watch function identified by KEY, so that it will not be called again.

RESET! (ATOM NEWVAL)

Set ATOM no NEWVAL, without regard to the previous value of ATOM.

RETRY-TRANSACTION

Signal a recoverable transaction error.

SEND (AGENT F &REST ARGS)

Enqueues an agent task to be performed by the thread-pool.

SEND-OFF (AGENT F &REST ARGS)

Executes an agent task in a new thread, if possible.

SET-SLOTS (OBJECT &REST SLOTS)

Provides copy-on-write semantics for CLOS objects, useful for REFERENCE types. With SET-SLOTS you can update a REFERENCE to point to a new, modified state, leaving the previous state intact for any threads that have a copy of it. Note that SET-SLOTS is a compatibility option for existing CLOS objects, and while it is slightly more space-efficient than using a HAMT, it is not nearly as fast.

SET-VALIDATOR (REF VALIDATOR)

Attempt to set a new VALIDATOR for an AGENT, ATOM, or REF.

SWAP! (ATOM F &REST ARGS)

Set the value of ATOM to the result of applying F.

TRY (ARG &REST FNS)

Attempt to apply each function in FNS to ARG until one returns a non-NIL value.

Undocumented

MAKE-REF (&REST ARGS)

MAKE-SEMAPHORE (&KEY NAME (COUNT 1))

SIGNAL-SEMAPHORE (SEMAPHORE)

TRY-SEMAPHORE (SEMAPHORE)

WAIT-ON-SEMAPHORE (SEMAPHORE)

Private

%AGENT-WRITERS (CLASS-NAME)

Define overloaded writer methods that implicitly enque their assignments on the agent thread pool.

%REFERENCE-READERS (CLASS-NAME)

Define overloaded reader methods that provide implicit dereferencing. These are just conveniences that allow you to type (reader ref) instead of cluttering your code with (reader @ref) or (reader (deref ref)).

ACQUIRE-LOCKS

Lock all the things!

AGENT-TASK-AGENT (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

AGENT-TASK-ARGS (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

AGENT-TASK-TASK (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

ATOMIC-WRITERS (CLASS-NAME)

Define overloaded writer methods that provide implicit synchronization. These are conveniences that allow you to write (setf (writer ref) newval) instead of (swap! ref (lambda (obj) (set-slots obj 'writer newval))

CALL-WATCHES (REF OLDVAL NEWVAL)

Private function to notify watches of changes in state.

MAKE-REFERENCE (&REST ARGS)

Shorthand for instantiating an object and wrapping it in a REFERENCE.

REFERENCE (&OPTIONAL VALUE VALIDATOR)

Function for creating a REFERENCE from a VALUE.

TASK-LIST-AGENT (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

TASK-LIST-TASKS (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

VALIDATE-READ-LOG

One last pass to be sure we're operating on a consistent snapshot.

Undocumented

%ENABLE-DEREF-SYNTAX

%ENABLE-MAP-SYNTAX

%VALIDP (VALIDATOR VALUE)

SETFAGENT-TASK-ARGS (NEW-VALUE INSTANCE)

AGENT-TASK-P (OBJECT)

SETFAGENT-TASK-TASK (NEW-VALUE INSTANCE)

COMMIT

COPY-AGENT-TASK (INSTANCE)

COPY-TASK-LIST (INSTANCE)

DEREF-SYNTAX-READER (STREAM CHAR)

MAKE-AGENT-TASK (&KEY ((AGENT DUM13) (ERROR required)) ((TASK DUM14) (ERROR required)) ((ARGS DUM15) NIL))

MAKE-TASK-LIST (&KEY ((AGENT DUM59) (ERROR required)) ((TASKS DUM60) NIL))

MAP-SYNTAX-READER (STREAM CHAR)

RUN-AGENTS (&OPTIONAL TASKS &KEY ONE-SHOT)

START-AGENTS (&OPTIONAL (NUM-THREADS 10))

TASK-LIST-P (OBJECT)

SETFTASK-LIST-TASKS (NEW-VALUE INSTANCE)

TIMESTAMP

VALIDP (REF NEWVAL)

MACRO

Public

-> (X &REST FORMS)

Threads X through FORMS in second postition.

->> (X &REST FORMS)

Threads X through FORMS in last position.

AGENT-PEXEC ((VAR AGENT) &BODY BODY)

Describe a procedure to be performed asynchronously in the context of a specific agent.

DEFINE-AGENT (CLASS (&REST SUPERS) &BODY BODY)

Declare a class with overloaded dereferencing readers and asynchronous writers.

DEFINE-ATOMIC (CLASS (&REST SUPERS) &BODY BODY)

Use DEFINE-ATOMIC to declare a class with both overloaded dereferencing readers and implicitly synchronized writers.

DEFINE-REFERENCE (CLASS (&REST SUPERS) &BODY BODY)

Use DEFINE-REFERENCE to declare a class and automatically generate overloaded dereferencing readers. Note that your classes should not derive from REFERENCE or any related REFERENCE-types.

DOSYNC ((&KEY READ-ONLY) &BODY BODY)

Execute a transaction.

ENABLE-DEREF-SYNTAX

Use @ to deref agents, atoms, or refs.

ENABLE-MAP-SYNTAX

Use {:key value} syntax for persistent hash-table literals.

FN (NAME (&REST ARGS) &BODY BODY)

A named lambda.

WITH-READ-LOCK ((RWLOCK) &BODY BODY)

Do BODY read-only in the scope of RWLOCK.

WITH-WRITE-LOCK ((RWLOCK) &BODY BODY)

Do BODY read/write in the scope of RWLOCK.

Undocumented

DEFINE-REF (CLASS (&REST SUPERS) &BODY BODY)

FUTURE (&BODY BODY)

WITH-SEMAPHORE ((SEMAPHORE) &BODY BODY)

Private

Undocumented

AGENT-WRITERS (CLASS-NAME)

REFERENCE-READERS (CLASS-NAME)

SLOT-ACCESSOR

Public

DEREF (OBJECT)

Returns the VALUE of a PROMISE object, if any, otherwise waits, blocking, for the PROMISE to be DELIVERed.

Undocumented

GET-VALIDATOR (OBJECT)

VARIABLE

Private

*AGENTS-CHANNEL*

All agent messages are enqueued on this channel to be picked up by the thread pool.

*AGENTS-LIST*

Keeps track of in-use agents and their outstanding messages, to prevent conflicts. Each item in the list is a TASK-LIST.

*AGENTS-MUTEX*

Locks the *AGENTS-LIST*.

Undocumented

*VERSION-CLOCK*

CLASS

Public

AGENT (&OPTIONAL VALUE VALIDATOR)

AGENTs provide for asynchronous, uncoordinated mutation of state.

ATOMIC (&OPTIONAL VALUE VALIDATOR)

ATOMIC references provide for synchronous, uncoordinated access to state.

PROMISE

A PROMISE object can be read with DEREF and set, once only, with DELIVER.

READ-WRITE-LOCK

Portable implementation of a fair readers/writers lock.

Undocumented

REF (VALUE &OPTIONAL VALIDATOR)

Private

AGENT-TASK

An individual task to be performed asynchronously by an agent.

REFERENCE (&OPTIONAL VALUE VALIDATOR)

A REFERENCE is, fundamentally, a pointer. The purpose is to provide a clean separation of object identity (the pointer) and state (the pointee). The REFERENCE remains constant even as the state changes. The higher-level abstractions (AGENTs, ATOMs, and REFs) provide different strategies for managing the state, each applicable to different situations.

TASK-LIST

A list of outstanding tasks for a specific agent.

CONDITION

Public

Undocumented

ABORT-TRANSACTION

RETRY-TRANSACTION