author  wenzelm 
Tue, 18 Dec 2007 22:21:42 +0100  
changeset 25704  df9c8074ff09 
parent 24690  c661dae1070a 
child 25735  4d147263f71f 
permissions  rwrr 
24690
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

1 
(* Title: Pure/MLSystems/multithreading.ML 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

2 
ID: $Id$ 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

3 
Author: Makarius 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

4 

c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

5 
Dummy implementation of multithreading interface. 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

6 
*) 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

7 

25704  8 
signature BASIC_MULTITHREADING = 
9 
sig 

10 
val NAMED_CRITICAL: string > (unit > 'a) > 'a 

11 
val CRITICAL: (unit > 'a) > 'a 

12 
end; 

13 

24690
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

14 
signature MULTITHREADING = 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

15 
sig 
25704  16 
include BASIC_MULTITHREADING 
24690
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

17 
val trace: int ref 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

18 
val tracing: int > (unit > string) > unit 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

19 
val available: bool 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

20 
val max_threads: int ref 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

21 
val self_critical: unit > bool 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

22 
datatype 'a task = 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

23 
Task of {body: unit > unit, cont: 'a > 'a, fail: 'a > 'a}  Wait  Terminate; 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

24 
val schedule: int > ('a > 'a task * 'a) > 'a > exn list 
25704  25 
val serial: unit > int 
24690
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

26 
end; 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

27 

c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

28 
structure Multithreading: MULTITHREADING = 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

29 
struct 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

30 

c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

31 
val trace = ref (0: int); 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

32 
fun tracing _ _ = (); 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

33 

c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

34 
val available = false; 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

35 
val max_threads = ref (1: int); 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

36 

c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

37 
fun self_critical () = false; 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

38 
fun NAMED_CRITICAL _ e = e (); 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

39 
fun CRITICAL e = e (); 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

40 

c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

41 
datatype 'a task = 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

42 
Task of {body: unit > unit, cont: 'a > 'a, fail: 'a > 'a}  Wait  Terminate; 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

43 

c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

44 
fun schedule _ _ _ = raise Fail "No multithreading support"; 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

45 

25704  46 
local val count = ref (0: int) 
47 
in fun serial () = (count := ! count + 1; ! count) end; 

48 

24690
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

49 
end; 
c661dae1070a
renamed MLSystems/multithreading_dummy.ML to MLSystems/multithreading.ML;
wenzelm
parents:
diff
changeset

50 

25704  51 
structure BasicMultithreading: BASIC_MULTITHREADING = Multithreading; 
52 
open BasicMultithreading; 

53 