Commits

Anonymous committed 6cb4c0a

+ TlsArray (single-threaded implementation only!)

  • Participants
  • Parent commits d3dbcf9

Comments (0)

Files changed (7)

   Path:       src
   BuildTools: ocamlbuild
   BuildDepends: num
-  Modules:    Cadastr, Monoid, Cd_All, Cd_Int, Cd_List, Cd_Ops, Cd_Byte, Cd_Bytes, Cd_Chars, Cd_Strings, Cd_Array, Cd_Typeinfo, Cdt, Cd_Types, Cd_Option, Cd_Num, Cd_Tuples, Cd_Bool
+  Modules:    Cadastr, Monoid, Cd_All, Cd_Int, Cd_List, Cd_Ops, Cd_Byte, Cd_Bytes, Cd_Chars, Cd_Strings, Cd_Array, Cd_Typeinfo, Cdt, Cd_Types, Cd_Option, Cd_Num, Cd_Tuples, Cd_Bool, TlsArray
 
 Executable tests
   Path:       test
 (* setup.ml generated for the first time by OASIS v0.2.1~alpha1 *)
 
 (* OASIS_START *)
-(* DO NOT EDIT (digest: 5bb6db20dc826ac6d349df0135f5437c) *)
+(* DO NOT EDIT (digest: 1769685deea28a04aa4d1f9cab63606f) *)
 (*
    Regenerated by OASIS v0.2.1~alpha1
    Visit http://oasis.forge.ocamlcore.org for more information and
                            "Cd_Option";
                            "Cd_Num";
                            "Cd_Tuples";
-                           "Cd_Bool"
+                           "Cd_Bool";
+                           "TlsArray"
                         ];
                       lib_internal_modules = [];
                       lib_findlib_parent = None;

File src/cadastr.mllib

 # OASIS_START
-# DO NOT EDIT (digest: 5457f9b62e6982fd87096d6215b6073e)
+# DO NOT EDIT (digest: 2a534a88bb51735de2187b345448957f)
 Cadastr
 Monoid
 Cd_All
 Cd_Num
 Cd_Tuples
 Cd_Bool
+TlsArray
 # OASIS_STOP

File src/tlsArray.ml

+include TlsArray_st;

File src/tlsArray.mli

+(*
+  TlsArray is an array that has size, default value and allows
+  to set/get its items from any thread, giving each thread a
+  separate array to work with.
+  An unset items are assigned the default value.
+ *)
+
+type t 'a;
+
+value make : int -> 'a -> t 'a;
+
+value length : t 'a -> int;
+
+value get : t 'a -> int -> 'a;
+
+value set : t 'a -> int -> 'a -> unit;
+
+(* returns current thread's array, which can be mutated in-place *)
+value get_array : t 'a -> array 'a;
+
+(* open this module to use the usual "arr.(i)" and "arr.(i) := x"
+   notation. *)
+module Ops
+ :
+  sig
+    module Array
+     :
+      sig
+        value get : t 'a -> int -> 'a;
+        value set : t 'a -> int -> 'a -> unit;
+      end
+    ;
+  end
+;

File src/tlsArray_mt.ml

+(*
+implementation of multithreaded TlsArray
+*)

File src/tlsArray_st.ml

+(*
+implementation of singlethreaded TlsArray
+*)
+
+type t 'a = array 'a;
+
+value make = Array.make;
+
+value set = Array.set;
+
+value get = Array.get;
+
+value length = Array.length;
+
+value get_array x = x;
+
+module Ops
+ =
+  struct
+    module Array
+     =
+      struct
+        value get = get;
+        value set = set;
+      end
+    ;
+  end
+;