From 8d922d13bd5c2f09a476a07578d523b4bed38933 Mon Sep 17 00:00:00 2001
From: Dorian Weber <weber@informatik.hu-berlin.de>
Date: Mon, 15 Feb 2021 12:49:15 +0100
Subject: [PATCH] Fixed a subtle bug with regards to the Promise.

---
 src/lib.rs | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/lib.rs b/src/lib.rs
index 4b6f41a..8c51b76 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -565,8 +565,9 @@ impl<T> Promise<T> {
 	
 	/// Writes the result value and reawakens the caller.
 	pub fn fulfill(&self, result: T) {
-		self.result.replace(Some(result));
-		self.caller.wake_by_ref();
+		if self.result.replace(Some(result)).is_none() {
+			self.caller.wake_by_ref();
+		}
 	}
 	
 	/// Extracts the written value and resets the state of the promise.
-- 
GitLab