added str_of;
authorwenzelm
Mon, 29 Sep 2008 21:26:46 +0200
changeset 28415 bf08f955e7db
parent 28414 419954d26886
child 28416 263599f1346a
added str_of;
src/Pure/Concurrent/future.ML
--- a/src/Pure/Concurrent/future.ML	Mon Sep 29 21:26:44 2008 +0200
+++ b/src/Pure/Concurrent/future.ML	Mon Sep 29 21:26:46 2008 +0200
@@ -33,6 +33,7 @@
   type 'a T
   val task_of: 'a T -> task
   val group_of: 'a T -> group
+  val str_of: 'a T -> string
   val is_finished: 'a T -> bool
   val future: group option -> task list -> bool -> (unit -> 'a) -> 'a T
   val fork: (unit -> 'a) -> 'a T
@@ -72,6 +73,12 @@
 fun task_of (Future {task, ...}) = task;
 fun group_of (Future {group, ...}) = group;
 
+fun str_of (Future {result, ...}) =
+  (case ! result of
+    NONE => "<future>"
+  | SOME (Exn.Result _) => "<finished future>"
+  | SOME (Exn.Exn _) => "<failed future>");
+
 fun is_finished (Future {result, ...}) = is_some (! result);