Dummy version of state variables -- plain refs for sequential access.
authorwenzelm
Mon, 28 Sep 2009 23:51:13 +0200
changeset 32736 f126e68d003d
parent 32735 f96f3ae3a19d
child 32737 76fa673eee8b
child 32759 1476fe841023
child 32772 50d090ca93f8
Dummy version of state variables -- plain refs for sequential access.
src/Pure/Concurrent/synchronized_dummy.ML
src/Pure/IsaMakefile
src/Pure/ML-Systems/thread_dummy.ML
src/Pure/ROOT.ML
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Pure/Concurrent/synchronized_dummy.ML	Mon Sep 28 23:51:13 2009 +0200
@@ -0,0 +1,25 @@
+(*  Title:      Pure/Concurrent/synchronized_dummy.ML
+    Author:     Makarius
+
+Dummy version of state variables -- plain refs for sequential access.
+*)
+
+structure Synchronized: SYNCHRONIZED =
+struct
+
+datatype 'a var = Var of 'a ref;
+
+fun var _ x = Var (ref x);
+fun value (Var var) = ! var;
+
+fun timed_access (Var var) _ f =
+  (case f (! var) of
+    SOME (y, x') => (var := x'; SOME y)
+  | NONE => Thread.unavailable ());
+
+fun guarded_access var f = the (timed_access var (K NONE) f);
+
+fun change_result var f = guarded_access var (SOME o f);
+fun change var f = change_result var (fn x => ((), f x));
+
+end;
--- a/src/Pure/IsaMakefile	Mon Sep 28 23:19:50 2009 +0200
+++ b/src/Pure/IsaMakefile	Mon Sep 28 23:51:13 2009 +0200
@@ -45,32 +45,33 @@
 $(OUT)/Pure: $(BOOTSTRAP_FILES) Concurrent/future.ML			\
   Concurrent/mailbox.ML Concurrent/par_list.ML				\
   Concurrent/par_list_dummy.ML Concurrent/simple_thread.ML		\
-  Concurrent/synchronized.ML Concurrent/task_queue.ML General/alist.ML	\
-  General/antiquote.ML General/balanced_tree.ML General/basics.ML	\
-  General/binding.ML General/buffer.ML General/file.ML			\
-  General/graph.ML General/heap.ML General/integer.ML General/lazy.ML	\
-  General/long_name.ML General/markup.ML General/name_space.ML		\
-  General/ord_list.ML General/output.ML General/path.ML			\
-  General/position.ML General/pretty.ML General/print_mode.ML		\
-  General/properties.ML General/queue.ML General/same.ML		\
-  General/scan.ML General/secure.ML General/seq.ML General/source.ML	\
-  General/stack.ML General/symbol.ML General/symbol_pos.ML		\
-  General/table.ML General/url.ML General/xml.ML General/yxml.ML	\
-  Isar/args.ML Isar/attrib.ML Isar/auto_bind.ML Isar/calculation.ML	\
-  Isar/class.ML Isar/class_target.ML Isar/code.ML Isar/constdefs.ML	\
-  Isar/context_rules.ML Isar/element.ML Isar/expression.ML		\
-  Isar/isar_cmd.ML Isar/isar_document.ML Isar/isar_syn.ML		\
-  Isar/local_defs.ML Isar/local_syntax.ML Isar/local_theory.ML		\
-  Isar/locale.ML Isar/method.ML Isar/object_logic.ML Isar/obtain.ML	\
-  Isar/outer_keyword.ML Isar/outer_lex.ML Isar/outer_parse.ML		\
-  Isar/outer_syntax.ML Isar/overloading.ML Isar/proof.ML		\
-  Isar/proof_context.ML Isar/proof_display.ML Isar/proof_node.ML	\
-  Isar/rule_cases.ML Isar/rule_insts.ML Isar/runtime.ML			\
-  Isar/skip_proof.ML Isar/spec_parse.ML Isar/specification.ML		\
-  Isar/theory_target.ML Isar/toplevel.ML Isar/value_parse.ML		\
-  ML/ml_antiquote.ML ML/ml_compiler.ML ML/ml_compiler_polyml-5.3.ML	\
-  ML/ml_context.ML ML/ml_env.ML ML/ml_lex.ML ML/ml_parse.ML		\
-  ML/ml_syntax.ML ML/ml_thms.ML ML-Systems/install_pp_polyml.ML		\
+  Concurrent/synchronized.ML Concurrent/synchronized_dummy.ML		\
+  Concurrent/task_queue.ML General/alist.ML General/antiquote.ML	\
+  General/balanced_tree.ML General/basics.ML General/binding.ML		\
+  General/buffer.ML General/file.ML General/graph.ML General/heap.ML	\
+  General/integer.ML General/lazy.ML General/long_name.ML		\
+  General/markup.ML General/name_space.ML General/ord_list.ML		\
+  General/output.ML General/path.ML General/position.ML			\
+  General/pretty.ML General/print_mode.ML General/properties.ML		\
+  General/queue.ML General/same.ML General/scan.ML General/secure.ML	\
+  General/seq.ML General/source.ML General/stack.ML General/symbol.ML	\
+  General/symbol_pos.ML General/table.ML General/url.ML General/xml.ML	\
+  General/yxml.ML Isar/args.ML Isar/attrib.ML Isar/auto_bind.ML		\
+  Isar/calculation.ML Isar/class.ML Isar/class_target.ML Isar/code.ML	\
+  Isar/constdefs.ML Isar/context_rules.ML Isar/element.ML		\
+  Isar/expression.ML Isar/isar_cmd.ML Isar/isar_document.ML		\
+  Isar/isar_syn.ML Isar/local_defs.ML Isar/local_syntax.ML		\
+  Isar/local_theory.ML Isar/locale.ML Isar/method.ML			\
+  Isar/object_logic.ML Isar/obtain.ML Isar/outer_keyword.ML		\
+  Isar/outer_lex.ML Isar/outer_parse.ML Isar/outer_syntax.ML		\
+  Isar/overloading.ML Isar/proof.ML Isar/proof_context.ML		\
+  Isar/proof_display.ML Isar/proof_node.ML Isar/rule_cases.ML		\
+  Isar/rule_insts.ML Isar/runtime.ML Isar/skip_proof.ML			\
+  Isar/spec_parse.ML Isar/specification.ML Isar/theory_target.ML	\
+  Isar/toplevel.ML Isar/value_parse.ML ML/ml_antiquote.ML		\
+  ML/ml_compiler.ML ML/ml_compiler_polyml-5.3.ML ML/ml_context.ML	\
+  ML/ml_env.ML ML/ml_lex.ML ML/ml_parse.ML ML/ml_syntax.ML		\
+  ML/ml_thms.ML ML-Systems/install_pp_polyml.ML				\
   ML-Systems/install_pp_polyml-5.3.ML ML-Systems/use_context.ML		\
   Proof/extraction.ML Proof/proof_rewrite_rules.ML			\
   Proof/proof_syntax.ML Proof/proofchecker.ML Proof/reconstruct.ML	\
--- a/src/Pure/ML-Systems/thread_dummy.ML	Mon Sep 28 23:19:50 2009 +0200
+++ b/src/Pure/ML-Systems/thread_dummy.ML	Mon Sep 28 23:51:13 2009 +0200
@@ -35,6 +35,8 @@
   datatype threadAttribute = EnableBroadcastInterrupt of bool | InterruptState of interruptState
     and interruptState = InterruptDefer | InterruptSynch | InterruptAsynch | InterruptAsynchOnce;
 
+  fun unavailable () = fail ();
+
   fun fork _ = fail ();
   fun exit _ = fail ();
   fun isActive _ = fail ();
--- a/src/Pure/ROOT.ML	Mon Sep 28 23:19:50 2009 +0200
+++ b/src/Pure/ROOT.ML	Mon Sep 28 23:51:13 2009 +0200
@@ -58,6 +58,7 @@
 
 use "Concurrent/simple_thread.ML";
 use "Concurrent/synchronized.ML";
+if Multithreading.available then () else use "Concurrent/synchronized_dummy.ML";
 use "Concurrent/mailbox.ML";
 use "Concurrent/task_queue.ML";
 use "Concurrent/future.ML";