(*
(* in foo.sml *)
val doublespec : (unit,int,int) extspec =
{
self_dir = change "directory where foo.sig is located",
self = "foo.doublespec",
parallel_dir = default_parallel_dir,
reflect_globals = "()",
function = let fun f _ (x:int) = 2 * x in f end,
write_param = let fun f _ () = () in f end,
read_param = let fun f _ = () in f end,
write_arg = let fun f file arg = writel file [its arg] in f end,
read_arg = let fun f file =
string_to_int (singleton_of_list (readl file)) in f end,
write_result = let fun f file r = writel file [its r] in f end,
read_result = let fun f file = string_to_int (hd (readl_rm file)) in f end
}
(* in foo.sig *)
val doublespec : (unit,int,int) extspec
*)
- load "smlParallel"; open smlParallel; load "foo"; open foo;
(* output omitted *)
> val it = (): unit
- parmap_queue_extern 2 doublespec () [1,2,3];
(* output omitted *)
> val it = [2, 4, 6]: int list