Common Lisp Package: CL-STM

README:

FUNCTION

Public

RETRY

Return a transaction that when executed, aborts the current transaction and re-executes it from scratch. The transaction will wait on all variables that have been read so far during the transaction.

Undocumented

CURRENT-TLOG

RECORDING?

STMS (FORMS)

UNSTMS (FORMS)

UNTRANS (TRANSACTION)

Private

NEXT-TRANSACTION-ID

Return the next transaction id.

Undocumented

ENSURE-GENERIC-FUNCTION (FUN-NAME &REST ALL-KEYS &KEY ENVIRONMENT DEFINITION-SOURCE &ALLOW-OTHER-KEYS)

EXTRACT-FTYPE-DECLARATIONS (DECLS)

EXTRACT-TYPE-DECLARATIONS (DECLS)

RETURNING?

STM-LOGGER.LEVEL

SETFSTM-LOGGER.LEVEL (LEVEL)

STMB (BINDS)

UNSTMB (BINDS)

MACRO

Public

DEFTCLASS (CLASS (&REST SUPERCLASSES) (&REST SLOTS) &REST CLASS-OPTIONS)

Define a new transactional class caleed CLASS. DEFTCLASS is just like DEFCLASS except the default metaclass is transactional class, slots are transactional, and it inherits from TRANSACTIONAL-OBJECT by default.

DEFTRANSACTION (NAME (&REST ARGS) &BODY BODY)

Define a new transaction called NAME. DEFTRANSACTION is just like DEFMETHOD but the body is walked into an STM action.

TRANS (BODY)

Create a new anonymous transaction.

TRY (&BODY BODY)

Return a transaction that executes each transaction in BODY atomically from left to right until one succeeds. The return value of the transaction is the value of the transaction that succeeds.

WITH-NEW-TLOG (VAR &BODY BODY)

Execute BODY with the default transaction log being a newly allocated transaction log bound to VAR.

WITH-RECORDING (&BODY BODY)

Turn recording of reads and writes on. Recording is normally on inside transactions.

WITH-STM (FORM)

Execute FORM as if it were run in the STM.

WITH-TLOG (LOG &BODY BODY)

Execute BODY with the default transasction log being LOG.

WITHOUT-RECORDING (&BODY BODY)

Turn recording of reads and writes off. Recording is normally off outside transactions (ie at the REPL) and when initializing transactional objects.

Private

DEFSTM-WALKER (CLASS (&REST SLOTS) &BODY BODY)

Define a STM walker. It takes the class of a CL form object, and its slots as arguments. It binds the form object to the variable *FORM*.

DEFUNSTM-WALKER (CLASS (&REST SLOTS) &BODY BODY)

Define a UNSTM walker. It takes the class of a CL form object, and its slots as arguments. It binds the form object to the variable *FORM*.

UNTIL (TEST &BODY BODY)

Repeat BODY until TEST is false. You may exit the loop with (RETURN-FROM UNTIL).

Undocumented

DEFCLASS (&ENVIRONMENT ENV NAME DIRECT-SUPERCLASSES DIRECT-SLOTS &REST OPTIONS)

DEFGENERIC (&WHOLE FORM NAME (&REST ARGS) &BODY OPTIONS)

DEFMETHOD (&WHOLE FORM NAME &BODY BODY &ENVIRONMENT ENV)

INCF-MOD (PLACE DIVISOR)

STM-LOGGER.DEBUG (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM-LOGGER.DRIBBLE (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM-LOGGER.ERROR (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM-LOGGER.FATAL (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM-LOGGER.INFO (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM-LOGGER.WARN (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.CHECK.DEBUG (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.CHECK.DRIBBLE (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.CHECK.ERROR (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.CHECK.FATAL (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.CHECK.INFO (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.CHECK.WARN (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.COMMIT.DEBUG (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.COMMIT.DRIBBLE (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.COMMIT.ERROR (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.COMMIT.FATAL (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.COMMIT.INFO (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.COMMIT.WARN (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.EXECUTE.DEBUG (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.EXECUTE.DRIBBLE (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.EXECUTE.ERROR (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.EXECUTE.FATAL (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.EXECUTE.INFO (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.EXECUTE.WARN (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.ORELSE.DEBUG (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.ORELSE.DRIBBLE (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.ORELSE.ERROR (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.ORELSE.FATAL (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.ORELSE.INFO (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.ORELSE.WARN (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.PERFORM.DEBUG (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.PERFORM.DRIBBLE (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.PERFORM.ERROR (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.PERFORM.FATAL (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.PERFORM.INFO (MESSAGE-CONTROL &REST MESSAGE-ARGS)

STM.PERFORM.WARN (MESSAGE-CONTROL &REST MESSAGE-ARGS)

WITH-DECLARATIONS (DECLS &BODY BODY)

WITH-RETURNING (&BODY BODY)

WITH-TRANS-FUNS (FUNS &BODY BODY)

WITH-TRANS-VARS (VARS &BODY BODY)

WITHOUT-RETURNING (&BODY BODY)

GENERIC-FUNCTION

Public

CHECK? (LOG)

Check that LOG is consistent. It returns a boolean specifying whether or not LOG is valid with respect to the current Common Lisp world. CHECK can be used to see if a transaction isn't consistent before committing it.

COMMIT (LOG)

Commit a LOG to memory. It returns a boolean specifying whether or not the transaction log was committed. If the transaction log couldn't be committed it probably means that another transaction log that writes the same variables is being committed.

EXECUTE (TRANSACTION)

Execute TRANSACTION and return 3 values. 1. A boolean specifying whether or not the transaction retried. 2. A transaction log of all the changes that occured. 3. A list of values that TRANSACTION returns.

MERGE-LOGS (LOG1 LOG2)

Merge LOG1 and LOG2. Any reads and writes in LOG2 shadow the reads and writes in LOG1.

ORELSE (TX1 TX2)

Compose two transactions alternatively. ORELSE returns a new transaction. We perform TX1 and if it succeeds then we're done. If it fails then we perform TX2. If performing TX2 succeeds then we're done. If it fails we try to perform TX1 again, and so on. The transaction's return value (not ORELSE's) is nondeterministic because we can't tell in advance which transaction succeeds. ORELSE is just the plumbing behind the TRY macro, which is just a variable arity version of ORELSE.

PERFORM (TRANSACTION &KEY WAIT?)

Run TRANSACTION atomically with respect to all other threads in a new thread. If the transaction retries, then the thread loops again re-executing the transaction and commiting it to memory. When WAIT? is true, then PERFORM returns the result of executing TRANSACTION. Otherwise PERFORM returns a thread created by BORDEAUX-THREADS as its value.

READ-TVAR (VAR LOG)

Record the reading of VAR to LOG. READ-TVAR is only called when transactions are being recorded, and LOG is normally the special variable *LOG*. READ-TVAR is just the plumbing behind taking the SLOT-VALUE of a transactional slot. Just use readers and accessors as you normally would on transactional objects.

STM (FORM)

Translate FORM into an STM action. Define methods on this generic function with DEFSTM-WALKER.

UNSTM (FORM)

Translate FORM from a STM action to a Lisp form. Define methods on this generic function with DEFUNSTM-WALKER.

UNWAIT (VAR)

UNWAIT causes all threads waiting for VAR to change to wake up.

WAIT (LOG)

WAIT causes the current thread to wait for a change in any of LOG's reads and writes.

WRITE-TVAR (VAR LOG VAL)

Record the writing of VAL to VAR to LOG. WRITE-TVAR is only called when transactions are being recorded, and LOG is normally the special variable *LOG*. WRITE-TVAR is just the plumbing behind SETF'ing a transactional slot. Just use SETF as you normally would on transactional objects.

Undocumented

DECREMENT (C &OPTIONAL (D))

DEQ (Q &KEY REMOVE? BLOCK?)

EMPTY! (CELL)

EMPTY? (CELL)

ENQ (Q VAL)

FULL? (Q)

INCREMENT (C &OPTIONAL (D))

NOB (TX)

PUT (CELL VAL)

QLENGTH (Q)

READ-PORT (P)

REPEAT (TX N)

RESET (C)

SLEEP-AFTER (TX SECS)

SWAP (C1 C2)

TAKE (CELL)

TRY-PUT (CELL VAL)

WRITE-CHAN (C ITEM)

Private

BIND (TX1 TX2)

Compose two transactions sequentially. BIND returns a new transaction. If either TX1 or TX2 retries then the whole transaction retries. The transaction's return value (not BIND's) is the return value of TX2.

Undocumented

MOVE-HEAD (Q)

MOVE-TAIL (Q)

TRANS-FORM (FORM)

TRANSACTION-ARGUMENTS (FORM)

TRANSACTION-FUNCTION? (FORM)

TRY-TAKE (CELL)

UNTRANS-FORM (FORM)

SLOT-ACCESSOR

Public

Undocumented

COUNT-OF (OBJECT)

SETFCOUNT-OF (NEW-VALUE OBJECT)

Private

READS-OF (OBJECT)

Mapping reads done to versions

SETFREADS-OF (NEW-VALUE OBJECT)

Mapping reads done to versions

WRITES-OF (OBJECT)

Mapping variables written to new values

SETFWRITES-OF (NEW-VALUE OBJECT)

Mapping variables written to new values

Undocumented

BUFFER-OF (OBJECT)

SETFBUFFER-OF (NEW-VALUE OBJECT)

CHAN-OF (OBJECT)

SETFCHAN-OF (NEW-VALUE OBJECT)

ELSE (OBJECT)

SETFELSE (NEW-VALUE OBJECT)

HEAD-OF (OBJECT)

SETFHEAD-OF (NEW-VALUE OBJECT)

ID-OF (OBJECT)

SETFID-OF (NEW-VALUE OBJECT)

INDEX-OF (OBJECT)

SETFINDEX-OF (NEW-VALUE OBJECT)

LOCK-OF (OBJECT)

SETFLOCK-OF (NEW-VALUE OBJECT)

SEMAPHORE-OF (OBJECT)

SETFSEMAPHORE-OF (NEW-VALUE OBJECT)

SIZE-OF (OBJECT)

SETFSIZE-OF (NEW-VALUE OBJECT)

SLOT-TRANSACTIONAL (OBJECT)

SETFSLOT-TRANSACTIONAL (NEW-VALUE OBJECT)

SPECIALIZER (OBJECT)

SETFSPECIALIZER (NEW-VALUE OBJECT)

TAIL-OF (OBJECT)

SETFTAIL-OF (NEW-VALUE OBJECT)

THUNK-OF (OBJECT)

SETFTHUNK-OF (NEW-VALUE OBJECT)

VALUE-OF (OBJECT)

SETFVALUE-OF (NEW-VALUE OBJECT)

VERSION-OF (OBJECT)

SETFVERSION-OF (NEW-VALUE OBJECT)

WAITING-FOR (OBJECT)

SETFWAITING-FOR (NEW-VALUE OBJECT)

WAITING-LOCK-OF (OBJECT)

SETFWAITING-LOCK-OF (NEW-VALUE OBJECT)

VARIABLE

Private

*FORM*

This contains the current form that is being walked.

*RECORD-TRANSACTIONS*

A boolean specifying whether or not transactions are recorded to log.

*RETURN-CONTENTS*

A boolean specifying whether or not slot accessors should return the contents of the transactional variable instead of the variable itself.

*TLOG*

The current transaction log.

*TRANS-FUNS*

When walking code, this variable contains a list of functions (represented by symbols) which return transactions when applied.

*TRANS-VARS*

When walking code, this variable contains a list of variables (represented by symbols) which are transactions.

*TRANSACTION-COUNTER*

A counter used for the ID of transactions.

*TRANSACTION-COUNTER-LOCK*

A lock around *TRANSACTION-COUNTER*.

Undocumented

*EMPTY-CELL*

CLASS

Public

TLOG

A transaction log (TLOG) is a record of what reads and writes have been done. Transaction logs are written during the execution of a transaction (using READ-TVAR and WRITE-TVAR). Transactions logs are committed to memory by COMMIT later on.

TRANSACTIONAL-CLASS

The metaclass for transactional classes. Classes defined with this metaclass have extra slot options, see the class TRANSACTIONAL-DIRECT-SLOT for details.

TRANSACTIONAL-DIRECT-SLOT

The class for direct slots of transactional classes. Other than the initargs for standard slots the following options can be passed to component slots: :transactional [ T | NIL ] - Specify that this slot is a transactional slot and that all reads and writes should be committed to log.

TRANSACTIONAL-EFFECTIVE-SLOT

The class for effective slots of transactional classes. Exactly like TRANSACTIONAL-EFFECTIVE-SLOT.

TRANSACTIONAL-OBJECT

Superclass of all transactional objects.

TVAR

A transactional variable (TVAR) holds a value. See READ-TVAR and WRITE-TVAR for reading and writing them.

Undocumented

CELL

CHAN

COUNTER

PORT

SEQUENCE

STANDARD-TLOG

STANDARD-TRANSACTION

STANDARD-TVAR

TQUEUE

TRANSACTION

Private

Undocumented

STANDARD-CLASS

STANDARD-GENERIC-FUNCTION

TRANS-FORM (FORM)

UNTRANS-FORM (FORM)