|
|
|
@ -33,14 +33,14 @@ class Status { |
|
|
|
|
Status& operator=(const Status& s); |
|
|
|
|
Status(Status&& s) |
|
|
|
|
#if !(defined _MSC_VER) || ((defined _MSC_VER) && (_MSC_VER >= 1900)) |
|
|
|
|
noexcept |
|
|
|
|
noexcept |
|
|
|
|
#endif |
|
|
|
|
; |
|
|
|
|
; |
|
|
|
|
Status& operator=(Status&& s) |
|
|
|
|
#if !(defined _MSC_VER) || ((defined _MSC_VER) && (_MSC_VER >= 1900)) |
|
|
|
|
noexcept |
|
|
|
|
noexcept |
|
|
|
|
#endif |
|
|
|
|
; |
|
|
|
|
; |
|
|
|
|
bool operator==(const Status& rhs) const; |
|
|
|
|
bool operator!=(const Status& rhs) const; |
|
|
|
|
|
|
|
|
@ -58,7 +58,7 @@ class Status { |
|
|
|
|
kAborted = 10, |
|
|
|
|
kBusy = 11, |
|
|
|
|
kExpired = 12, |
|
|
|
|
kTryAgain = 13, |
|
|
|
|
kTryAgain = 13 |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Code code() const { return code_; } |
|
|
|
@ -68,6 +68,7 @@ class Status { |
|
|
|
|
kMutexTimeout = 1, |
|
|
|
|
kLockTimeout = 2, |
|
|
|
|
kLockLimit = 3, |
|
|
|
|
kNoSpace = 4, |
|
|
|
|
kMaxSubCode |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -157,6 +158,11 @@ class Status { |
|
|
|
|
return Status(kTryAgain, msg, msg2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static Status NoSpace() { return Status(kIOError, kNoSpace); } |
|
|
|
|
static Status NoSpace(const Slice& msg, const Slice& msg2 = Slice()) { |
|
|
|
|
return Status(kIOError, kNoSpace, msg, msg2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Returns true iff the status indicates success.
|
|
|
|
|
bool ok() const { return code() == kOk; } |
|
|
|
|
|
|
|
|
@ -200,6 +206,15 @@ class Status { |
|
|
|
|
// re-attempted.
|
|
|
|
|
bool IsTryAgain() const { return code() == kTryAgain; } |
|
|
|
|
|
|
|
|
|
// Returns true iff the status indicates a NoSpace error
|
|
|
|
|
// This is caused by an I/O error returning the specific "out of space"
|
|
|
|
|
// error condition. Stricto sensu, an NoSpace error is an I/O error
|
|
|
|
|
// with a specific subcode, enabling users to take the appropriate action
|
|
|
|
|
// if needed
|
|
|
|
|
bool IsNoSpace() const { |
|
|
|
|
return (code() == kIOError) && (subcode() == kNoSpace); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Return a string representation of this status suitable for printing.
|
|
|
|
|
// Returns the string "OK" for success.
|
|
|
|
|
std::string ToString() const; |
|
|
|
@ -219,7 +234,10 @@ class Status { |
|
|
|
|
explicit Status(Code _code, SubCode _subcode = kNone) |
|
|
|
|
: code_(_code), subcode_(_subcode), state_(nullptr) {} |
|
|
|
|
|
|
|
|
|
Status(Code _code, const Slice& msg, const Slice& msg2); |
|
|
|
|
Status(Code _code, SubCode _subcode, const Slice& msg, const Slice& msg2); |
|
|
|
|
Status(Code _code, const Slice& msg, const Slice& msg2) |
|
|
|
|
: Status(_code, kNone, msg, msg2) {} |
|
|
|
|
|
|
|
|
|
static const char* CopyState(const char* s); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -229,7 +247,7 @@ inline Status::Status(const Status& s) : code_(s.code_), subcode_(s.subcode_) { |
|
|
|
|
inline Status& Status::operator=(const Status& s) { |
|
|
|
|
// The following condition catches both aliasing (when this == &s),
|
|
|
|
|
// and the common case where both s and *this are ok.
|
|
|
|
|
if(this != &s) { |
|
|
|
|
if (this != &s) { |
|
|
|
|
code_ = s.code_; |
|
|
|
|
subcode_ = s.subcode_; |
|
|
|
|
delete[] state_; |
|
|
|
@ -240,23 +258,23 @@ inline Status& Status::operator=(const Status& s) { |
|
|
|
|
|
|
|
|
|
inline Status::Status(Status&& s) |
|
|
|
|
#if !(defined _MSC_VER) || ((defined _MSC_VER) && (_MSC_VER >= 1900)) |
|
|
|
|
noexcept |
|
|
|
|
noexcept |
|
|
|
|
#endif |
|
|
|
|
: Status() { |
|
|
|
|
: Status() { |
|
|
|
|
*this = std::move(s); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline Status& Status::operator=(Status&& s) |
|
|
|
|
#if !(defined _MSC_VER) || ((defined _MSC_VER) && (_MSC_VER >= 1900)) |
|
|
|
|
noexcept |
|
|
|
|
noexcept |
|
|
|
|
#endif |
|
|
|
|
{ |
|
|
|
|
if(this != &s) { |
|
|
|
|
if (this != &s) { |
|
|
|
|
code_ = std::move(s.code_); |
|
|
|
|
s.code_ = kOk; |
|
|
|
|
subcode_ = std::move(s.subcode_); |
|
|
|
|
s.subcode_ = kNone; |
|
|
|
|
delete [] state_; |
|
|
|
|
delete[] state_; |
|
|
|
|
state_ = nullptr; |
|
|
|
|
std::swap(state_, s.state_); |
|
|
|
|
} |
|
|
|
|