Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/branches/SMLNJ/src/cml/src/core-cml/rep-types.sml
ViewVC logotype

Annotation of /sml/branches/SMLNJ/src/cml/src/core-cml/rep-types.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8 - (view) (download)

1 : monnier 2 (* rep-types.sml
2 :     *
3 :     * COPYRIGHT (c) 1995 AT&T Bell Laboratories.
4 :     * COPYRIGHT (c) 1989-1991 John H. Reppy
5 :     *
6 :     * These are the concrete representations of the various CML types.
7 :     * These types are abstract (or not even visible) outside this library.
8 :     *)
9 :    
10 :     structure RepTypes =
11 :     struct
12 :    
13 :     (* queues --- see queue.sml *)
14 :     datatype 'a queue = Q of {
15 :     front : 'a list ref,
16 :     rear : 'a list ref
17 :     }
18 :    
19 :     (** thread IDs --- see threads.sml **)
20 :     datatype thread_id = TID of { (* thread ids *)
21 :     id : int, (* an unique ID *)
22 :     alert : bool ref, (* true, if there is a pending alert on this *)
23 :     (* thread *)
24 :     done_comm : bool ref, (* set this whenever this thread does some *)
25 :     (* concurrency operation. *)
26 :     exnHandler : (exn -> unit) ref, (* root-level exception handler hook *)
27 :     dead : cvar (* the cvar that becomes set when the thread *)
28 :     (* dies *)
29 :     }
30 :    
31 :     (* transaction IDs are used to mark blocked threads in the various waiting
32 :     * queues. They are "cancelled" when some other event is selected.
33 :     *)
34 :     and trans_id
35 :     = CANCEL
36 :     | TRANS of thread_id
37 :    
38 :     (* Condition variables --- see events.sml.
39 :     * These are essentially unit valued ivars, and are used for various
40 :     * internal synchronization conditions (e.g., nack events, I/O
41 :     * synchronization, and thread termination).
42 :     *)
43 :     and cvar = CVAR of cvar_state ref
44 :     and cvar_state
45 :     = CVAR_unset of {
46 :     transId : trans_id ref,
47 :     cleanUp : unit -> unit,
48 :     kont : unit SMLofNJ.Cont.cont
49 :     } list
50 :     | CVAR_set of int
51 :    
52 :     (** events --- see events.sml **)
53 :     datatype 'a event_status
54 :     = ENABLED of {prio : int, doFn : unit -> 'a}
55 :     | BLOCKED of {
56 :     transId : trans_id ref, cleanUp : unit -> unit, next : unit -> unit
57 :     } -> 'a
58 :    
59 :     type 'a base_evt = unit -> 'a event_status
60 :    
61 :     datatype 'a event
62 :     = BEVT of 'a base_evt list
63 :     | CHOOSE of 'a event list
64 :     | GUARD of unit -> 'a event
65 :     | W_NACK of unit event -> 'a event
66 :    
67 : monnier 8 (* we put this function here, because it is useful when debugging the
68 :     * CML internals.
69 :     *)
70 :     fun tidToString (TID{id, ...}) =
71 :     concat["[", StringCvt.padLeft #"0" 6 (Int.toString id), "]"]
72 :    
73 : monnier 2 end

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0