aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/threading/future/core/future.h
diff options
context:
space:
mode:
authorilnurkh <ilnurkh@yandex-team.com>2024-07-26 15:19:25 +0300
committerilnurkh <ilnurkh@yandex-team.com>2024-07-26 15:31:14 +0300
commit696e048df66bace916e830df8fc37349098d22cf (patch)
treef23871493d3a95d3a2b96ea58e7591118277fbd2 /library/cpp/threading/future/core/future.h
parent43c64f9b535d8e793a95647872127d2843ac0f01 (diff)
downloadydb-696e048df66bace916e830df8fc37349098d22cf.tar.gz
TFuture add IsReady method
IsReady returns true if exception or value was set. allows to check readiness without locking cheсker-thread NOTE: returns true even if value was extracted from promise good replace for HasValue() || HasException() b2d64093e25cef5a350dfebe784c449203a5b383
Diffstat (limited to 'library/cpp/threading/future/core/future.h')
-rw-r--r--library/cpp/threading/future/core/future.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/library/cpp/threading/future/core/future.h b/library/cpp/threading/future/core/future.h
index 598336282a..1e76a04d3f 100644
--- a/library/cpp/threading/future/core/future.h
+++ b/library/cpp/threading/future/core/future.h
@@ -98,6 +98,12 @@ namespace NThreading {
void TryRethrow() const;
bool HasException() const;
+ // returns true if exception or value was set.
+ // allows to check readiness without locking cheker-thread
+ // NOTE: returns true even if value was extracted from promise
+ // good replace for HasValue() || HasException()
+ bool IsReady() const;
+
void Wait() const;
bool Wait(TDuration timeout) const;
bool Wait(TInstant deadline) const;
@@ -153,6 +159,11 @@ namespace NThreading {
void TryRethrow() const;
bool HasException() const;
+ // returns true if exception or value was set.
+ // allows to check readiness without locking cheker-thread
+ // good replace for HasValue() || HasException()
+ bool IsReady() const;
+
void Wait() const;
bool Wait(TDuration timeout) const;
bool Wait(TInstant deadline) const;
@@ -216,6 +227,12 @@ namespace NThreading {
void TryRethrow() const;
bool HasException() const;
+
+ // returns true if exception or value was set.
+ // allows to check readiness without locking cheker-thread
+ // NOTE: returns true even if value was extracted from promise
+ // good replace for HasValue() || HasException()
+ bool IsReady() const;
void SetException(const TString& e);
void SetException(std::exception_ptr e);
bool TrySetException(std::exception_ptr e);
@@ -256,6 +273,11 @@ namespace NThreading {
void TryRethrow() const;
bool HasException() const;
+
+ // returns true if exception or value was set.
+ // allows to check readiness without locking cheker-thread
+ // good replace for HasValue() || HasException()
+ bool IsReady() const;
void SetException(const TString& e);
void SetException(std::exception_ptr e);
bool TrySetException(std::exception_ptr e);