mesos-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benjamin Mahler <bmah...@apache.org>
Subject CHECK_NOTNONE / CHECK_NOTERROR
Date Tue, 10 Apr 2018 21:20:21 GMT
Just an FYI about some recently added CHECKs that make some minor changes
to the way we write code:

(1) CHECK_NOTNONE:

Much like glog's CHECK_NOTNULL, sometimes you know from invariants that an
Option cannot be in the none state and you want to "de-reference" it
without writing logic to handle the none case:

Option<T> func(...);
T t = CHECK_NOTNULL(func(...));

Option<T> some_option = ...;
T t = CHECK_NOTNONE(std::move(some_option));

Our existing code tends to use unguarded .get() calls, so hopefully this
new pattern makes it clearer when we're assuming an option is in the some
case.

(2) CHECK_NOTERROR:

This is the same, but for Try:

Try<T> func(...);
T t = CHECK_NOTERROR(func(...));

Try<T> some_try = ...;
T t = CHECK_NOTERROR(std::move(some_try));

You can find them here:
https://github.com/apache/mesos/blob/88f5629e510d71a32bd7e0ff7ee09e150f944e72/3rdparty/stout/include/stout/check.hpp

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message