diff options
Diffstat (limited to 'gee/promise.vala')
-rw-r--r-- | gee/promise.vala | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/gee/promise.vala b/gee/promise.vala index 020138e..ed7b872 100644 --- a/gee/promise.vala +++ b/gee/promise.vala @@ -92,11 +92,9 @@ public class Gee.Promise<G> { public unowned G wait () throws FutureError { _mutex.lock (); State state = _state; - if (_state == State.INIT) { - while (_state == State.INIT) { - _set.wait (_mutex); - state = _state; - } + while (_state == State.INIT) { + _set.wait (_mutex); + state = _state; } _mutex.unlock (); switch (state) { @@ -114,17 +112,19 @@ public class Gee.Promise<G> { public bool wait_until (int64 end_time, out unowned G? value = null) throws FutureError { _mutex.lock (); State state = _state; - if (state == State.INIT) { - while (_state == State.INIT) { - if (!_set.wait_until (_mutex, end_time)) { - value = null; - _mutex.unlock (); - return false; - } - state = _state; + bool res = true; + while (_state == State.INIT) { + res = _set.wait_until (_mutex, end_time); + if (!res) { + break; } + state = _state; } _mutex.unlock (); + if (!res) { + value = null; + return false; + } switch (state) { case State.ABANDON: throw new FutureError.ABANDON_PROMISE ("Promise has been abandon"); |