2 * 2004 Matthew
Fluet (mfluet@acm
.org
)
3 * Ported to MLton threads
.
8 * COPYRIGHT (c
) 1995 AT
&T Bell Laboratories
.
9 * COPYRIGHT (c
) 1989-1991 John H
. Reppy
12 structure TransID
: TRANS_ID
=
14 structure Assert
= LocalAssert(val assert
= false)
16 structure R
= RepTypes
19 (* Transaction IDs are used to mark blocked threads
in the various waiting
20 * queues
. They are
"cancelled" when some other event is selected
.
22 datatype trans_id
= datatype R
.trans_id
23 datatype trans_id_state
= datatype R
.trans_id_state
25 (* create a new transaction ID
. *)
26 fun mkTxId () = TXID(ref TRANS
)
28 (* create a transaction
flag (ID
and cleanUp
). *)
31 val txid
as TXID txst
= mkTxId ()
32 val cleanUp
= fn () =>
33 (Assert
.assertAtomic
' ("TransID.mkFlg.cleanUp", NONE
)
39 (* given a transaction ID
, mark it cancelled
. *)
40 fun force (TXID txst
) =
41 (Assert
.assertAtomic
' ("TransID.force", NONE
)
43 TRANS
=> txst
:= CANCEL
44 | CANCEL
=> raise Fail
"TransID.force")
47 fun toString (TXID txst
) =