summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/clj/clojure/core.clj3
-rw-r--r--src/clj/clojure/core_print.clj4
-rw-r--r--src/clj/clojure/pprint/dispatch.clj3
-rw-r--r--src/jvm/clojure/lang/IPromiseImpl.java15
4 files changed, 22 insertions, 3 deletions
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj
index 9f42e1da..2664d0d9 100644
--- a/src/clj/clojure/core.clj
+++ b/src/clj/clojure/core.clj
@@ -5955,6 +5955,9 @@
(reify
clojure.lang.IDeref
(deref [_] (.await d) @v)
+ clojure.lang.IPromiseImpl
+ (hasValue [this]
+ (= 0 (.getCount d)))
clojure.lang.IFn
(invoke [this x]
(locking d
diff --git a/src/clj/clojure/core_print.clj b/src/clj/clojure/core_print.clj
index dad509a7..a3c2e14a 100644
--- a/src/clj/clojure/core_print.clj
+++ b/src/clj/clojure/core_print.clj
@@ -325,6 +325,8 @@
(agent-error o))
" FAILED"
""))
- pr-on, "", ">", (list (if (and (future? o) (not (future-done? o))) :pending @o)), w))
+ pr-on, "", ">", (list (cond (and (future? o) (not (future-done? o))) :pending
+ (and (instance? clojure.lang.IPromiseImpl o) (not (.hasValue o))) :not-delivered
+ :else @o)), w))
(def ^{:private true} print-initialized true)
diff --git a/src/clj/clojure/pprint/dispatch.clj b/src/clj/clojure/pprint/dispatch.clj
index 99a131c8..a6ae2931 100644
--- a/src/clj/clojure/pprint/dispatch.clj
+++ b/src/clj/clojure/pprint/dispatch.clj
@@ -107,8 +107,6 @@
(def ^{:private true} pprint-set (formatter-out "~<#{~;~@{~w~^ ~:_~}~;}~:>"))
-;;; TODO: don't block on promise (currently impossible)
-
(def ^{:private true}
type-map {"core$future_call" "Future",
"core$promise" "Promise"})
@@ -133,6 +131,7 @@
(pprint-newline :linear)
(write-out (cond
(and (future? o) (not (future-done? o))) :pending
+ (and (instance? clojure.lang.IPromiseImpl o) (not (.hasValue o))) :not-delivered
:else @o)))))
(def ^{:private true} pprint-pqueue (formatter-out "~<<-(~;~@{~w~^ ~_~}~;)-<~:>"))
diff --git a/src/jvm/clojure/lang/IPromiseImpl.java b/src/jvm/clojure/lang/IPromiseImpl.java
new file mode 100644
index 00000000..686e4389
--- /dev/null
+++ b/src/jvm/clojure/lang/IPromiseImpl.java
@@ -0,0 +1,15 @@
+/**
+ * Copyright (c) Rich Hickey. All rights reserved.
+ * The use and distribution terms for this software are covered by the
+ * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
+ * which can be found in the file epl-v10.html at the root of this distribution.
+ * By using this software in any fashion, you are agreeing to be bound by
+ * the terms of this license.
+ * You must not remove this notice, or any other, from this software.
+ **/
+
+package clojure.lang;
+
+public interface IPromiseImpl {
+ boolean hasValue();
+}