From 89720d3c63bbd22cbccc80cdc92c2f2dd20193ba Mon Sep 17 00:00:00 2001 From: Lutz Bichler Date: Tue, 27 Oct 2020 10:02:03 +0100 Subject: capicxx-core-runtime 3.2.0 --- src/CommonAPI/CallInfo.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/CommonAPI/CallInfo.cpp (limited to 'src/CommonAPI/CallInfo.cpp') diff --git a/src/CommonAPI/CallInfo.cpp b/src/CommonAPI/CallInfo.cpp new file mode 100644 index 0000000..189e9d8 --- /dev/null +++ b/src/CommonAPI/CallInfo.cpp @@ -0,0 +1,40 @@ +// Copyright (C) 2015-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include +#include + +namespace CommonAPI { + +CallInfo::CallInfo() + : CallInfo(DEFAULT_SEND_TIMEOUT_MS, 0) { +} + +CallInfo::CallInfo(Timeout_t _timeout) + : CallInfo(_timeout, 0) { +} + +CallInfo::CallInfo(const CallInfo &_other) + : CallInfo(_other.timeout_, _other.sender_) { +} + +CallInfo::CallInfo(Timeout_t _timeout, Sender_t _sender) + : timeout_(_timeout), sender_(_sender) { + + Timeout_t defaultCallTimeout = Runtime::get()->getDefaultCallTimeout(); + const char *env = std::getenv("COMMONAPI_OVERRIDE_GLOBAL_CALL_TIMEOUT"); + + if ((_timeout == DEFAULT_SEND_TIMEOUT_MS) && defaultCallTimeout) { + timeout_ = defaultCallTimeout; + } + if (env) { + Timeout_t globalCallTimeout = std::stoi(env); + if (0 <= globalCallTimeout || globalCallTimeout == -1) { + timeout_ = globalCallTimeout; + } + } +} + +} // namespace CommonAPI \ No newline at end of file -- cgit v1.2.1