diff --git a/src/lib.rs b/src/lib.rs index 4b6f41a0408c1d4d2e946ac53097b2f658817f79..8c51b768d921bbe76c6337a8cf7c5fd8aafe80d7 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.