diff --git a/.gitmodules b/.gitmodules index 88533c9fd..d786b85b9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,3 +16,6 @@ [submodule "test/Catch2"] path = test/Catch2 url = https://github.com/catchorg/Catch2 +[submodule "external/optional-lite"] + path = external/optional-lite + url = https://github.com/martinmoene/optional-lite.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 01d15c026..2780480dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -254,6 +254,7 @@ if(SUBMODULE_CHECK) check_submodule(external/googletest) check_submodule(external/cxxopts) check_submodule(external/ghc-filesystem) + check_submodule(external/optional-lite) endif() endif() @@ -266,6 +267,7 @@ set(JSON_BuildTests OFF CACHE INTERNAL "") add_subdirectory(external/nlohmann EXCLUDE_FROM_ALL) add_subdirectory(external/cxxopts) add_subdirectory(external/ghc-filesystem) +add_subdirectory(external/optional-lite) if(ANDROID) list(APPEND LIBS log) diff --git a/external/optional-lite b/external/optional-lite new file mode 160000 index 000000000..3b79f4ee5 --- /dev/null +++ b/external/optional-lite @@ -0,0 +1 @@ +Subproject commit 3b79f4ee539d8f4c709a76b95a13564b6d9ae9cb diff --git a/libabyss/include/abyss/server.hpp b/libabyss/include/abyss/server.hpp index e77015d79..b0f52441a 100644 --- a/libabyss/include/abyss/server.hpp +++ b/libabyss/include/abyss/server.hpp @@ -7,7 +7,9 @@ #include #include -#include +#include +#include + #include #include #include @@ -27,7 +29,7 @@ namespace abyss IRPCHandler(ConnImpl* impl); - virtual absl::optional< Response > + virtual Response HandleJSONRPC(Method_t method, const Params& params) = 0; virtual ~IRPCHandler(); diff --git a/libabyss/main.cpp b/libabyss/main.cpp index 274a6968d..cae073ce2 100644 --- a/libabyss/main.cpp +++ b/libabyss/main.cpp @@ -13,12 +13,11 @@ struct DemoHandler : public abyss::httpd::IRPCHandler { } - absl::optional< Response > - HandleJSONRPC(Method_t method, - ABSL_ATTRIBUTE_UNUSED const Params& params) override + nonstd::optional< Response > + HandleJSONRPC(Method_t method, const Params& /*params*/) override { llarp::LogInfo("method: ", method); - return Response::object(); + return nonstd::make_optional(Response::object()); } }; diff --git a/libabyss/src/server.cpp b/libabyss/src/server.cpp index 03cbb0fa1..58848488e 100644 --- a/libabyss/src/server.cpp +++ b/libabyss/src/server.cpp @@ -184,15 +184,15 @@ namespace abyss { nlohmann::json response; response["jsonrpc"] = "2.0"; - response["id"] = m_Request["id"]; + response["id"] = m_Request["id"].get< std::string >(); auto value = handler->HandleJSONRPC( m_Request["method"].get< std::string >(), m_Request["params"]); - if(value) - { - response["result"] = value.value(); - return WriteResponseJSON(response); - } + + if(!value.is_null()) + response["result"] = std::move(value); + + return WriteResponseJSON(response); } return WriteResponseSimple(500, "internal error", "text/plain", "nope"); diff --git a/llarp/CMakeLists.txt b/llarp/CMakeLists.txt index 60ce388e9..a757f3ebf 100644 --- a/llarp/CMakeLists.txt +++ b/llarp/CMakeLists.txt @@ -73,11 +73,12 @@ target_link_libraries(${UTIL_LIB} PUBLIC absl::synchronization absl::flat_hash_map absl::container nlohmann_json::nlohmann_json ghc_filesystem + optional-lite ) # cut back on fluff if (NOT WIN32) - target_link_libraries(${UTIL_LIB} PUBLIC absl::optional absl::variant absl::strings) + target_link_libraries(${UTIL_LIB} PUBLIC absl::variant absl::strings) endif(NOT WIN32) if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") diff --git a/llarp/config/config.cpp b/llarp/config/config.cpp index a62c3fa77..4c83e4dbc 100644 --- a/llarp/config/config.cpp +++ b/llarp/config/config.cpp @@ -35,7 +35,7 @@ namespace llarp return std::atoi(str.c_str()); } - absl::optional< bool > + nonstd::optional< bool > setOptBool(string_view val) { if(IsTrueValue(val)) diff --git a/llarp/config/config.hpp b/llarp/config/config.hpp index f227b7eec..97d14efbd 100644 --- a/llarp/config/config.hpp +++ b/llarp/config/config.hpp @@ -75,9 +75,9 @@ namespace llarp } template <> - inline absl::optional< bool > - fromEnv< absl::optional< bool > >(const absl::optional< bool >& val, - string_view envNameSuffix) + inline nonstd::optional< bool > + fromEnv< nonstd::optional< bool > >(const nonstd::optional< bool >& val, + string_view envNameSuffix) { std::string envName = absl::StrCat("LOKINET_", envNameSuffix); const char* ptr = std::getenv(envName.c_str()); @@ -112,7 +112,7 @@ namespace llarp // long term identity key std::string m_identKeyfile = "identity.key"; - absl::optional< bool > m_blockBogons; + nonstd::optional< bool > m_blockBogons; bool m_publicOverride = false; struct sockaddr_in m_ip4addr; @@ -142,7 +142,7 @@ namespace llarp int workerThreads() const { return fromEnv(m_workerThreads, "WORKER_THREADS"); } int numNetThreads() const { return fromEnv(m_numNetThreads, "NUM_NET_THREADS"); } std::string defaultLinkProto() const { return fromEnv(m_DefaultLinkProto, "LINK_PROTO"); } - absl::optional< bool > blockBogons() const { return fromEnv(m_blockBogons, "BLOCK_BOGONS"); } + nonstd::optional< bool > blockBogons() const { return fromEnv(m_blockBogons, "BLOCK_BOGONS"); } // clang-format on void @@ -155,14 +155,14 @@ namespace llarp using NetConfig = std::unordered_multimap< std::string, std::string >; private: - absl::optional< bool > m_enableProfiling; + nonstd::optional< bool > m_enableProfiling; std::string m_routerProfilesFile = "profiles.dat"; std::string m_strictConnect; NetConfig m_netConfig; public: // clang-format off - absl::optional< bool > enableProfiling() const { return fromEnv(m_enableProfiling, "ENABLE_PROFILING"); } + nonstd::optional< bool > enableProfiling() const { return fromEnv(m_enableProfiling, "ENABLE_PROFILING"); } std::string routerProfilesFile() const { return fromEnv(m_routerProfilesFile, "ROUTER_PROFILES_FILE"); } std::string strictConnect() const { return fromEnv(m_strictConnect, "STRICT_CONNECT"); } const NetConfig& netConfig() const { return m_netConfig; } diff --git a/llarp/dht/context.cpp b/llarp/dht/context.cpp index 6538ba962..2340d109f 100644 --- a/llarp/dht/context.cpp +++ b/llarp/dht/context.cpp @@ -134,7 +134,7 @@ namespace llarp llarp_time_t exploreInterval) override; /// get localally stored introset by service address - absl::optional< llarp::service::EncryptedIntroSet > + nonstd::optional< llarp::service::EncryptedIntroSet > GetIntroSetByLocation(const Key_t& location) const override; void @@ -455,7 +455,7 @@ namespace llarp } } - absl::optional< llarp::service::EncryptedIntroSet > + nonstd::optional< llarp::service::EncryptedIntroSet > Context::GetIntroSetByLocation(const Key_t& key) const { auto itr = _services->nodes.find(key); diff --git a/llarp/dht/context.hpp b/llarp/dht/context.hpp index e79b8e354..9049a475e 100644 --- a/llarp/dht/context.hpp +++ b/llarp/dht/context.hpp @@ -101,7 +101,7 @@ namespace llarp Init(const Key_t& us, AbstractRouter* router, llarp_time_t exploreInterval) = 0; - virtual absl::optional< llarp::service::EncryptedIntroSet > + virtual nonstd::optional< llarp::service::EncryptedIntroSet > GetIntroSetByLocation(const Key_t& location) const = 0; virtual llarp_time_t diff --git a/llarp/dht/messages/gotintro.hpp b/llarp/dht/messages/gotintro.hpp index da2ade3f8..bf9fbb2a3 100644 --- a/llarp/dht/messages/gotintro.hpp +++ b/llarp/dht/messages/gotintro.hpp @@ -6,7 +6,7 @@ #include #include -#include +#include namespace llarp { @@ -20,7 +20,7 @@ namespace llarp /// txid uint64_t txid = 0; /// the key of a router closer in keyspace if iterative lookup - absl::optional< Key_t > closer; + nonstd::optional< Key_t > closer; GotIntroMessage(const Key_t& from) : IMessage(from) { diff --git a/llarp/messages/relay_commit.cpp b/llarp/messages/relay_commit.cpp index c5fb61f31..621578604 100644 --- a/llarp/messages/relay_commit.cpp +++ b/llarp/messages/relay_commit.cpp @@ -15,7 +15,7 @@ #include #include -#include +#include namespace llarp { @@ -187,7 +187,7 @@ namespace llarp // the actual hop std::shared_ptr< Hop > hop; - const absl::optional< llarp::Addr > fromAddr; + const nonstd::optional< llarp::Addr > fromAddr; LRCMFrameDecrypt(Context* ctx, Decrypter_ptr dec, const LR_CommitMessage* commit) @@ -196,7 +196,7 @@ namespace llarp , context(ctx) , hop(std::make_shared< Hop >()) , fromAddr(commit->session->GetRemoteRC().IsPublicRouter() - ? absl::optional< llarp::Addr >{} + ? nonstd::optional< llarp::Addr >{} : commit->session->GetRemoteEndpoint()) { hop->info.downstream = commit->session->GetPubKey(); diff --git a/llarp/path/path.cpp b/llarp/path/path.cpp index b9f295a9a..52b77185f 100644 --- a/llarp/path/path.cpp +++ b/llarp/path/path.cpp @@ -138,7 +138,7 @@ namespace llarp uint64_t currentStatus = status; size_t index = 0; - absl::optional< RouterID > failedAt; + nonstd::optional< RouterID > failedAt; while(index < hops.size()) { if(!frames[index].DoDecrypt(hops[index].shared)) diff --git a/llarp/router_contact.cpp b/llarp/router_contact.cpp index b0530a558..0d8fe855c 100644 --- a/llarp/router_contact.cpp +++ b/llarp/router_contact.cpp @@ -165,7 +165,7 @@ namespace llarp nickname.Zero(); enckey.Zero(); pubkey.Zero(); - routerVersion = absl::optional< RouterVersion >{}; + routerVersion = nonstd::optional< RouterVersion >{}; last_updated = 0; } diff --git a/llarp/router_contact.hpp b/llarp/router_contact.hpp index 26d27e474..e103151a8 100644 --- a/llarp/router_contact.hpp +++ b/llarp/router_contact.hpp @@ -105,7 +105,7 @@ namespace llarp uint64_t last_updated = 0; uint64_t version = LLARP_PROTO_VERSION; - absl::optional< RouterVersion > routerVersion; + nonstd::optional< RouterVersion > routerVersion; util::StatusObject ExtractStatus() const; diff --git a/llarp/rpc/rpc.cpp b/llarp/rpc/rpc.cpp index 58f08c26b..2cd31aaf8 100644 --- a/llarp/rpc/rpc.cpp +++ b/llarp/rpc/rpc.cpp @@ -400,7 +400,7 @@ namespace llarp return resp; } - absl::optional< Response > + Response HandleJSONRPC(Method_t method, ABSL_ATTRIBUTE_UNUSED const Params& params) override { diff --git a/llarp/service/endpoint.cpp b/llarp/service/endpoint.cpp index a414ef058..75d4e99fe 100644 --- a/llarp/service/endpoint.cpp +++ b/llarp/service/endpoint.cpp @@ -922,7 +922,7 @@ namespace llarp bool Endpoint::OnLookup(const Address& addr, - absl::optional< const IntroSet > introset, + nonstd::optional< IntroSet > introset, const RouterID& endpoint) { const auto now = Router()->Now(); diff --git a/llarp/service/endpoint.hpp b/llarp/service/endpoint.hpp index e86168e6f..b496f6e3c 100644 --- a/llarp/service/endpoint.hpp +++ b/llarp/service/endpoint.hpp @@ -411,7 +411,7 @@ namespace llarp llarp_async_verify_rc* j); bool - OnLookup(const service::Address& addr, absl::optional< const IntroSet > i, + OnLookup(const service::Address& addr, nonstd::optional< IntroSet > i, const RouterID& endpoint); /* */ bool diff --git a/llarp/service/hidden_service_address_lookup.cpp b/llarp/service/hidden_service_address_lookup.cpp index 193a445fa..7da424c9f 100644 --- a/llarp/service/hidden_service_address_lookup.cpp +++ b/llarp/service/hidden_service_address_lookup.cpp @@ -23,7 +23,7 @@ namespace llarp HiddenServiceAddressLookup::HandleResponse( const std::set< EncryptedIntroSet >& results) { - absl::optional< IntroSet > found; + nonstd::optional< IntroSet > found; const Address remote(rootkey); LogInfo("found ", results.size(), " for ", remote.ToString()); if(results.size() > 0) diff --git a/llarp/service/hidden_service_address_lookup.hpp b/llarp/service/hidden_service_address_lookup.hpp index fcba8fdf0..55be3df13 100644 --- a/llarp/service/hidden_service_address_lookup.hpp +++ b/llarp/service/hidden_service_address_lookup.hpp @@ -16,7 +16,7 @@ namespace llarp uint64_t relayOrder; const dht::Key_t location; using HandlerFunc = std::function< bool( - const Address&, absl::optional< const IntroSet >, const RouterID&) >; + const Address&, nonstd::optional< IntroSet >, const RouterID&) >; HandlerFunc handle; HiddenServiceAddressLookup(Endpoint* p, HandlerFunc h, diff --git a/llarp/service/identity.cpp b/llarp/service/identity.cpp index 4ebdd3cae..dcf39ebdd 100644 --- a/llarp/service/identity.cpp +++ b/llarp/service/identity.cpp @@ -151,7 +151,7 @@ namespace llarp return crypto->derive_subkey_private(derivedSignKey, signkey, 1); } - absl::optional< EncryptedIntroSet > + nonstd::optional< EncryptedIntroSet > Identity::EncryptAndSignIntroSet(const IntroSet& other_i, llarp_time_t now) const { diff --git a/llarp/service/identity.hpp b/llarp/service/identity.hpp index c3e62e1bb..c31f8bcf4 100644 --- a/llarp/service/identity.hpp +++ b/llarp/service/identity.hpp @@ -47,7 +47,7 @@ namespace llarp bool DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* buf); - absl::optional< EncryptedIntroSet > + nonstd::optional< EncryptedIntroSet > EncryptAndSignIntroSet(const IntroSet& i, llarp_time_t now) const; bool diff --git a/llarp/service/info.hpp b/llarp/service/info.hpp index c86584576..4db312640 100644 --- a/llarp/service/info.hpp +++ b/llarp/service/info.hpp @@ -6,7 +6,7 @@ #include #include -#include +#include namespace llarp { @@ -23,7 +23,7 @@ namespace llarp VanityNonce vanity; uint64_t version = LLARP_PROTO_VERSION; - using OptNonce = absl::optional< VanityNonce >; + using OptNonce = nonstd::optional< VanityNonce >; void RandomizeVanity() diff --git a/llarp/service/intro_set.cpp b/llarp/service/intro_set.cpp index 790dc9924..15ed76158 100644 --- a/llarp/service/intro_set.cpp +++ b/llarp/service/intro_set.cpp @@ -84,7 +84,7 @@ namespace llarp return out; } - absl::optional< IntroSet > + nonstd::optional< IntroSet > EncryptedIntroSet::MaybeDecrypt(const PubKey& root) const { SharedSecret k(root); @@ -176,7 +176,7 @@ namespace llarp if(key == "w") { - W = absl::make_optional< PoW >(); + W.emplace(); return bencode_decode_dict(*W, buf); } diff --git a/llarp/service/intro_set.hpp b/llarp/service/intro_set.hpp index 522dd671a..ddb5d87b3 100644 --- a/llarp/service/intro_set.hpp +++ b/llarp/service/intro_set.hpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include @@ -31,7 +31,7 @@ namespace llarp PQPubKey K; Tag topic; llarp_time_t T = 0; - absl::optional< PoW > W; + nonstd::optional< PoW > W; Signature Z; uint64_t version = LLARP_PROTO_VERSION; @@ -111,7 +111,7 @@ namespace llarp llarp_time_t signedAt = 0; Payload_t introsetPayload; TunnelNonce nounce; - absl::optional< Tag > topic; + nonstd::optional< Tag > topic; Signature sig; bool @@ -145,7 +145,7 @@ namespace llarp util::StatusObject ExtractStatus() const; - absl::optional< IntroSet > + nonstd::optional< IntroSet > MaybeDecrypt(const PubKey& rootKey) const; }; diff --git a/llarp/service/outbound_context.cpp b/llarp/service/outbound_context.cpp index 64619364f..4167a6f19 100644 --- a/llarp/service/outbound_context.cpp +++ b/llarp/service/outbound_context.cpp @@ -86,9 +86,9 @@ namespace llarp } bool - OutboundContext::OnIntroSetUpdate( - const Address&, absl::optional< const IntroSet > foundIntro, - const RouterID& endpoint) + OutboundContext::OnIntroSetUpdate(const Address&, + nonstd::optional< IntroSet > foundIntro, + const RouterID& endpoint) { if(markedBad) return true; diff --git a/llarp/service/outbound_context.hpp b/llarp/service/outbound_context.hpp index 0468537da..938ddf3ce 100644 --- a/llarp/service/outbound_context.hpp +++ b/llarp/service/outbound_context.hpp @@ -115,7 +115,7 @@ namespace llarp OnGeneratedIntroFrame(AsyncKeyExchange* k, PathID_t p); bool - OnIntroSetUpdate(const Address& addr, absl::optional< const IntroSet > i, + OnIntroSetUpdate(const Address& addr, nonstd::optional< IntroSet > i, const RouterID& endpoint); const dht::Key_t location; diff --git a/llarp/util/fs.hpp b/llarp/util/fs.hpp index 002270ca3..772f728aa 100644 --- a/llarp/util/fs.hpp +++ b/llarp/util/fs.hpp @@ -16,7 +16,7 @@ namespace fs = ghc::filesystem; #include #endif -#include +#include namespace llarp { @@ -32,7 +32,7 @@ namespace llarp /// open a stream to a file and ensure it exists before open /// sets any permissions on creation template < typename T > - absl::optional< T > + nonstd::optional< T > OpenFileStream(fs::path pathname, std::ios::openmode mode) { if(EnsurePrivateFile(pathname)) diff --git a/llarp/util/logging/loglevel.cpp b/llarp/util/logging/loglevel.cpp index b7bb54e54..cbab3531a 100644 --- a/llarp/util/logging/loglevel.cpp +++ b/llarp/util/logging/loglevel.cpp @@ -45,7 +45,7 @@ namespace llarp } } - absl::optional< LogLevel > + nonstd::optional< LogLevel > LogLevelFromString(std::string level) { std::transform( diff --git a/llarp/util/logging/loglevel.hpp b/llarp/util/logging/loglevel.hpp index fbf39e385..75dbcdc39 100644 --- a/llarp/util/logging/loglevel.hpp +++ b/llarp/util/logging/loglevel.hpp @@ -1,7 +1,7 @@ #ifndef LLARP_UTIL_LOG_LEVEL_HPP #define LLARP_UTIL_LOG_LEVEL_HPP #include -#include +#include namespace llarp { @@ -22,7 +22,7 @@ namespace llarp std::string LogLevelToName(LogLevel lvl); - absl::optional< LogLevel > + nonstd::optional< LogLevel > LogLevelFromString(std::string level); } // namespace llarp diff --git a/llarp/util/meta/object.hpp b/llarp/util/meta/object.hpp index c53872997..e21e2b5e9 100644 --- a/llarp/util/meta/object.hpp +++ b/llarp/util/meta/object.hpp @@ -3,7 +3,7 @@ #include -#include +#include #include namespace llarp @@ -330,7 +330,7 @@ namespace llarp return true; } - absl::optional< Value > + nonstd::optional< Value > find(int32_t handle) { absl::ReaderMutexLock l(&m_mutex); diff --git a/llarp/util/metrics/core.cpp b/llarp/util/metrics/core.cpp index a7fceeaba..dd6805980 100644 --- a/llarp/util/metrics/core.cpp +++ b/llarp/util/metrics/core.cpp @@ -711,7 +711,7 @@ namespace llarp m_categories.clear(); } - absl::optional< absl::Duration > + nonstd::optional< absl::Duration > PublisherScheduler::find(const Category *category) const { util::Lock l(&m_mutex); @@ -725,7 +725,7 @@ namespace llarp return it->second; } - absl::optional< absl::Duration > + nonstd::optional< absl::Duration > PublisherScheduler::getDefault() const { util::Lock l(&m_mutex); diff --git a/llarp/util/metrics/core.hpp b/llarp/util/metrics/core.hpp index ba7006364..008e8168e 100644 --- a/llarp/util/metrics/core.hpp +++ b/llarp/util/metrics/core.hpp @@ -1193,16 +1193,16 @@ namespace llarp return m_manager; } - absl::optional< absl::Duration > + nonstd::optional< absl::Duration > find(string_view categoryName) const { return find(m_manager->registry().get(categoryName)); } - absl::optional< absl::Duration > + nonstd::optional< absl::Duration > find(const Category *category) const; - absl::optional< absl::Duration > + nonstd::optional< absl::Duration > getDefault() const; std::vector< std::pair< const Category *, absl::Duration > > diff --git a/llarp/util/metrics/metrictank_publisher.cpp b/llarp/util/metrics/metrictank_publisher.cpp index 58410843f..601b419f0 100644 --- a/llarp/util/metrics/metrictank_publisher.cpp +++ b/llarp/util/metrics/metrictank_publisher.cpp @@ -32,7 +32,7 @@ namespace llarp { namespace { - absl::optional< std::string > + nonstd::optional< std::string > makeStr(double d) { if(std::isnan(d) || std::isinf(d)) @@ -43,7 +43,7 @@ namespace llarp return std::to_string(d); } - absl::optional< std::string > + nonstd::optional< std::string > makeStr(int i) { if(i == std::numeric_limits< int >::min() @@ -56,7 +56,7 @@ namespace llarp } template < typename Value > - absl::optional< std::string > + nonstd::optional< std::string > formatValue(const Record< Value > &record, double elapsedTime, Publication::Type publicationType) { diff --git a/llarp/util/metrics/types.hpp b/llarp/util/metrics/types.hpp index d00b30e89..70f8d3e26 100644 --- a/llarp/util/metrics/types.hpp +++ b/llarp/util/metrics/types.hpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include @@ -78,7 +78,7 @@ namespace llarp struct Format { - using Spec = absl::optional< FormatSpec >; + using Spec = nonstd::optional< FormatSpec >; std::array< Spec, Publication::MaxSize > m_specs; @@ -92,10 +92,11 @@ namespace llarp m_specs[static_cast< size_t >(pub)].emplace(spec); } - constexpr void + void clear() { - m_specs = decltype(m_specs)(); + for(auto &s : m_specs) + s.reset(); } constexpr const FormatSpec * diff --git a/llarp/util/stopwatch.hpp b/llarp/util/stopwatch.hpp index 25a772c22..4e4354361 100644 --- a/llarp/util/stopwatch.hpp +++ b/llarp/util/stopwatch.hpp @@ -1,7 +1,7 @@ #ifndef LLARP_STOPWATCH_HPP #define LLARP_STOPWATCH_HPP -#include +#include #include namespace llarp @@ -10,8 +10,8 @@ namespace llarp { class Stopwatch { - absl::optional< absl::Time > m_start; - absl::optional< absl::Time > m_stop; + nonstd::optional< absl::Time > m_start; + nonstd::optional< absl::Time > m_stop; public: Stopwatch() = default; diff --git a/llarp/util/thread/logic.hpp b/llarp/util/thread/logic.hpp index 2e29622f0..b8d77edf4 100644 --- a/llarp/util/thread/logic.hpp +++ b/llarp/util/thread/logic.hpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include namespace llarp { @@ -54,7 +54,7 @@ namespace llarp using ID_t = std::thread::id; llarp_threadpool* const m_Thread; llarp_ev_loop* m_Loop = nullptr; - absl::optional< ID_t > m_ID; + nonstd::optional< ID_t > m_ID; util::ContentionKiller m_Killer; std::function< void(std::function< void(void) >) > m_Queue; }; diff --git a/llarp/util/thread/queue.hpp b/llarp/util/thread/queue.hpp index bdef5207e..6d5e1e00c 100644 --- a/llarp/util/thread/queue.hpp +++ b/llarp/util/thread/queue.hpp @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include @@ -73,7 +73,7 @@ namespace llarp Type popFront(); - absl::optional< Type > + nonstd::optional< Type > tryPopFront(); // Remove all elements from the queue. Note this is not atomic, and if @@ -260,7 +260,7 @@ namespace llarp } template < typename Type > - absl::optional< Type > + nonstd::optional< Type > Queue< Type >::tryPopFront() { uint32_t generation; @@ -285,7 +285,7 @@ namespace llarp // - notify any waiting pushers QueuePopGuard< Type > popGuard(*this, generation, index); - return absl::optional< Type >(std::move(m_data[index])); + return nonstd::optional< Type >(std::move(m_data[index])); } template < typename Type > diff --git a/llarp/util/thread/threading.hpp b/llarp/util/thread/threading.hpp index 4ebf47030..4ba72d360 100644 --- a/llarp/util/thread/threading.hpp +++ b/llarp/util/thread/threading.hpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include @@ -45,7 +45,7 @@ namespace llarp /// in debug mode, we implement lock() to enforce that any lock is only /// used from a single thread. the point of this is to identify locks that /// are actually needed by dying a painful death when used across threads - mutable absl::optional< std::thread::id > m_id; + mutable nonstd::optional< std::thread::id > m_id; void lock() const { diff --git a/llarp/util/thread/timerqueue.hpp b/llarp/util/thread/timerqueue.hpp index a36e74024..6297c2598 100644 --- a/llarp/util/thread/timerqueue.hpp +++ b/llarp/util/thread/timerqueue.hpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include @@ -273,7 +273,7 @@ namespace llarp return true; } - absl::optional< absl::Time > + nonstd::optional< absl::Time > nextTime() const { absl::ReaderMutexLock lock(&m_mutex); diff --git a/test/dht/mock_context.hpp b/test/dht/mock_context.hpp index 76f364051..30a2df05c 100644 --- a/test/dht/mock_context.hpp +++ b/test/dht/mock_context.hpp @@ -69,7 +69,7 @@ namespace llarp void(const dht::Key_t&, AbstractRouter*, llarp_time_t)); MOCK_CONST_METHOD1(GetIntroSetByLocation, - absl::optional< llarp::service::EncryptedIntroSet >( + nonstd::optional< llarp::service::EncryptedIntroSet >( const llarp::dht::Key_t&)); MOCK_CONST_METHOD0(ExtractStatus, util::StatusObject()); diff --git a/test/test_libabyss.cpp b/test/test_libabyss.cpp index 5bc384d58..1b169c9ee 100644 --- a/test/test_libabyss.cpp +++ b/test/test_libabyss.cpp @@ -107,7 +107,7 @@ struct ServerHandler : public abyss::httpd::IRPCHandler { } - absl::optional< Response > + Response HandleJSONRPC(Method_t method, ABSL_ATTRIBUTE_UNUSED const Params& params) { test->AssertMethod(method); diff --git a/test/util/meta/test_llarp_util_object.cpp b/test/util/meta/test_llarp_util_object.cpp index ef11f7006..d282125a7 100644 --- a/test/util/meta/test_llarp_util_object.cpp +++ b/test/util/meta/test_llarp_util_object.cpp @@ -50,7 +50,7 @@ TEST(Catalog, smoke) ASSERT_EQ(handle1, handle2); ASSERT_TRUE(catalog.find(handle1)); - absl::optional< double > result = catalog.find(handle1); + nonstd::optional< double > result = catalog.find(handle1); ASSERT_TRUE(result); ASSERT_EQ(value2, result); catalog.remove(handle2); @@ -80,7 +80,7 @@ TEST(Catalog, Iterator) for(size_t j = 0; j < ITERATION_COUNT; ++j) { int32_t handle = cat->add(id); - absl::optional< int32_t > res = cat->find(handle); + nonstd::optional< int32_t > res = cat->find(handle); ASSERT_TRUE(res); ASSERT_EQ(res.value(), id); ASSERT_TRUE(cat->replace(MAX - id, handle)); diff --git a/test/util/test_llarp_util_log_level.cpp b/test/util/test_llarp_util_log_level.cpp index 50b72b7dc..52cbdd05e 100644 --- a/test/util/test_llarp_util_log_level.cpp +++ b/test/util/test_llarp_util_log_level.cpp @@ -8,7 +8,7 @@ using TestString = std::string; struct TestParseLog { TestString input; - absl::optional< llarp::LogLevel > level; + nonstd::optional< llarp::LogLevel > level; }; struct LogLevelTest : public ::testing::TestWithParam< TestParseLog > diff --git a/test/util/thread/test_llarp_util_queue.cpp b/test/util/thread/test_llarp_util_queue.cpp index 2aa0849cd..2668cf650 100644 --- a/test/util/thread/test_llarp_util_queue.cpp +++ b/test/util/thread/test_llarp_util_queue.cpp @@ -585,7 +585,7 @@ TEST(TestQueue, moveIt) ASSERT_EQ(5u, counter); - absl::optional< MoveTester > optPopped = queue.tryPopFront(); + nonstd::optional< MoveTester > optPopped = queue.tryPopFront(); ASSERT_TRUE(optPopped.has_value()); diff --git a/test/util/thread/test_llarp_util_queue_manager.cpp b/test/util/thread/test_llarp_util_queue_manager.cpp index 0d5aa6729..3620de453 100644 --- a/test/util/thread/test_llarp_util_queue_manager.cpp +++ b/test/util/thread/test_llarp_util_queue_manager.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include @@ -75,7 +75,7 @@ class IntQueue } } - absl::optional< int > + nonstd::optional< int > tryPopFront() { uint32_t gen = 0;