summaryrefslogtreecommitdiff
path: root/src/components/telemetry_monitor/src/telemetry_monitor.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/telemetry_monitor/src/telemetry_monitor.cc')
-rw-r--r--src/components/telemetry_monitor/src/telemetry_monitor.cc80
1 files changed, 39 insertions, 41 deletions
diff --git a/src/components/telemetry_monitor/src/telemetry_monitor.cc b/src/components/telemetry_monitor/src/telemetry_monitor.cc
index 53a5a2dc70..d62724a479 100644
--- a/src/components/telemetry_monitor/src/telemetry_monitor.cc
+++ b/src/components/telemetry_monitor/src/telemetry_monitor.cc
@@ -1,34 +1,34 @@
/*
-* Copyright (c) 2014, Ford Motor Company
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-*
-* Redistributions of source code must retain the above copyright notice, this
-* list of conditions and the following disclaimer.
-*
-* Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following
-* disclaimer in the documentation and/or other materials provided with the
-* distribution.
-*
-* Neither the name of the Ford Motor Company nor the names of its contributors
-* may be used to endorse or promote products derived from this software
-* without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*/
+ * Copyright (c) 2014, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
#include "telemetry_monitor/telemetry_monitor.h"
@@ -42,8 +42,7 @@
#include "transport_manager/transport_manager_default.h"
#include "utils/resource_usage.h"
-#include "utils/make_shared.h"
-#include "utils/shared_ptr.h"
+
#include "telemetry_monitor/telemetry_observable.h"
namespace telemetry_monitor {
@@ -60,13 +59,11 @@ TelemetryMonitor::TelemetryMonitor(const std::string& server_address,
, ph_observer(this) {}
void TelemetryMonitor::Start() {
- streamer_ = streamer_ ? streamer_ : utils::MakeShared<Streamer>(this);
+ streamer_ = streamer_ ? streamer_ : std::make_shared<Streamer>(this);
thread_ = threads::CreateThread("TelemetryMonitor", streamer_.get());
}
-void TelemetryMonitor::set_streamer(Streamer* streamer) {}
-
-void TelemetryMonitor::set_streamer(utils::SharedPtr<Streamer> streamer) {
+void TelemetryMonitor::set_streamer(std::shared_ptr<Streamer> streamer) {
LOG4CXX_AUTO_TRACE(logger_);
if (thread_ && !thread_->is_running()) {
streamer_ = streamer;
@@ -115,7 +112,7 @@ void TelemetryMonitor::Stop() {
thread_ = NULL;
}
-void TelemetryMonitor::SendMetric(utils::SharedPtr<MetricWrapper> metric) {
+void TelemetryMonitor::SendMetric(std::shared_ptr<MetricWrapper> metric) {
if (streamer_ && streamer_->is_client_connected_) {
streamer_->PushMessage(metric);
}
@@ -149,7 +146,7 @@ void Streamer::threadMain() {
is_client_connected_ = true;
while (is_client_connected_) {
while (!messages_.empty()) {
- utils::SharedPtr<MetricWrapper> metric;
+ std::shared_ptr<MetricWrapper> metric;
if (!messages_.pop(metric)) {
continue;
}
@@ -251,8 +248,9 @@ bool Streamer::IsReady() const {
fd_set fds;
FD_ZERO(&fds);
FD_SET(client_socket_fd_, &fds);
- TimevalStruct tv = {0, 0};
- tv.tv_sec = 5; // set a 5 second timeout
+ // need to construct a timeval for the duration, can't use duration
+ struct timeval tv;
+ tv.tv_sec = 5;
tv.tv_usec = 0;
const int retval = select(client_socket_fd_ + 1, 0, &fds, 0, &tv);
@@ -282,7 +280,7 @@ bool Streamer::Send(const std::string& msg) {
return true;
}
-void Streamer::PushMessage(utils::SharedPtr<MetricWrapper> metric) {
+void Streamer::PushMessage(std::shared_ptr<MetricWrapper> metric) {
messages_.push(metric);
}
} // namespace telemetry_monitor