src/Pure/ML-Systems/multithreading.ML
author wenzelm
Mon Sep 08 20:33:29 2008 +0200 (2008-09-08)
changeset 28169 356fc8734741
parent 28160 e0177b67ecd9
child 28187 4062882c7df3
permissions -rw-r--r--
removed unused sync_interrupts;
wenzelm@24690
     1
(*  Title:      Pure/ML-Systems/multithreading.ML
wenzelm@24690
     2
    ID:         $Id$
wenzelm@24690
     3
    Author:     Makarius
wenzelm@24690
     4
wenzelm@28149
     5
Dummy implementation of multithreading setup.
wenzelm@24690
     6
*)
wenzelm@24690
     7
wenzelm@25704
     8
signature BASIC_MULTITHREADING =
wenzelm@25704
     9
sig
wenzelm@25704
    10
  val NAMED_CRITICAL: string -> (unit -> 'a) -> 'a
wenzelm@25704
    11
  val CRITICAL: (unit -> 'a) -> 'a
wenzelm@25704
    12
end;
wenzelm@25704
    13
wenzelm@24690
    14
signature MULTITHREADING =
wenzelm@24690
    15
sig
wenzelm@25704
    16
  include BASIC_MULTITHREADING
wenzelm@24690
    17
  val trace: int ref
wenzelm@24690
    18
  val tracing: int -> (unit -> string) -> unit
wenzelm@24690
    19
  val available: bool
wenzelm@24690
    20
  val max_threads: int ref
wenzelm@25775
    21
  val max_threads_value: unit -> int
wenzelm@28149
    22
  val no_interrupts: Thread.threadAttribute list
wenzelm@28160
    23
  val regular_interrupts: Thread.threadAttribute list
wenzelm@28160
    24
  val with_attributes: Thread.threadAttribute list ->
wenzelm@28160
    25
    (Thread.threadAttribute list -> 'a -> 'b) -> 'a -> 'b
wenzelm@24690
    26
  val self_critical: unit -> bool
wenzelm@25704
    27
  val serial: unit -> int
wenzelm@24690
    28
end;
wenzelm@24690
    29
wenzelm@24690
    30
structure Multithreading: MULTITHREADING =
wenzelm@24690
    31
struct
wenzelm@24690
    32
wenzelm@25735
    33
(* options *)
wenzelm@25735
    34
wenzelm@24690
    35
val trace = ref (0: int);
wenzelm@24690
    36
fun tracing _ _ = ();
wenzelm@24690
    37
wenzelm@24690
    38
val available = false;
wenzelm@24690
    39
val max_threads = ref (1: int);
wenzelm@25775
    40
fun max_threads_value () = Int.max (! max_threads, 1);
wenzelm@24690
    41
wenzelm@28149
    42
val no_interrupts = [];
wenzelm@28160
    43
val regular_interrupts = [];
wenzelm@28160
    44
wenzelm@28160
    45
fun with_attributes _ f x = f [] x;
wenzelm@28149
    46
wenzelm@25735
    47
wenzelm@25735
    48
(* critical section *)
wenzelm@25735
    49
wenzelm@24690
    50
fun self_critical () = false;
wenzelm@24690
    51
fun NAMED_CRITICAL _ e = e ();
wenzelm@24690
    52
fun CRITICAL e = e ();
wenzelm@24690
    53
wenzelm@25735
    54
wenzelm@25735
    55
(* serial numbers *)
wenzelm@25735
    56
wenzelm@25704
    57
local val count = ref (0: int)
wenzelm@25704
    58
in fun serial () = (count := ! count + 1; ! count) end;
wenzelm@25704
    59
wenzelm@28123
    60
end;
wenzelm@28123
    61
wenzelm@28123
    62
structure BasicMultithreading: BASIC_MULTITHREADING = Multithreading;
wenzelm@28123
    63
open BasicMultithreading;