Showing the changes to Source/Libraries/TimeSeriesPlatformLibrary/Samples/PublisherHandler.cpp (1 of 27 files). Show all
Unified · Split
| @@ -42,29 +42,23 @@ PublisherHandler::PublisherHandler(string name, uint16_t port, bool ipV6) : · 41 unmodified lines | ||
| 42 | 42 | void PublisherHandler::StatusMessage(const string& message) |
| 43 | 43 | { |
| 44 | 44 | // TODO: Make sure these messages get logged to an appropriate location |
| 45 | − // For now, the base class just displays to console: | |
| 46 | − stringstream status; | |
| 47 | − | |
| 48 | − status << "[" << m_name << "] " << message; | |
| 49 | 45 | |
| 50 | 46 | // Calls can come from multiple threads, so we impose a simple lock before write to console |
| 51 | − s_coutLock.lock(); | |
| 52 | − PublisherInstance::StatusMessage(status.str()); | |
| 53 | − s_coutLock.unlock(); | |
| 47 | + ScopeLock lock(s_coutLock); | |
| 48 | + | |
| 49 | + // For now, we just the base class to display to console: | |
| 50 | + PublisherInstance::StatusMessage("[" + m_name + "] " + message); | |
| 54 | 51 | } |
| 55 | 52 | |
| 56 | 53 | void PublisherHandler::ErrorMessage(const string& message) |
| 57 | 54 | { |
| 58 | 55 | // TODO: Make sure these messages get logged to an appropriate location |
| 59 | − // For now, the base class just displays to console: | |
| 60 | − stringstream status; | |
| 61 | − | |
| 62 | − status << "[" << m_name << "] " << message; | |
| 63 | 56 | |
| 64 | 57 | // Calls can come from multiple threads, so we impose a simple lock before write to console |
| 65 | − s_coutLock.lock(); | |
| 66 | − PublisherInstance::ErrorMessage(status.str()); | |
| 67 | − s_coutLock.unlock(); | |
| 58 | + ScopeLock lock(s_coutLock); | |
| 59 | + | |
| 60 | + // For now, we just the base class to display to console: | |
| 61 | + PublisherInstance::ErrorMessage("[" + m_name + "] " + message); | |
| 68 | 62 | } |
| 69 | 63 | |
| 70 | 64 | void PublisherHandler::ClientConnected(const SubscriberConnectionPtr& connection) |
| @@ -187,7 +181,8 @@ void PublisherHandler::Start() · 116 unmodified lines | ||
| 187 | 181 | // data type reasonable random values every 33 milliseconds |
| 188 | 182 | m_publishTimer = NewSharedPtr<Timer>(33, [this](Timer*, void*) |
| 189 | 183 | { |
| 190 | − static uint32_t count = m_measurementMetadata.size(); | |
| 184 | + // If metadata can change, the following integer should not be static: | |
| 185 | + static uint32_t count = ConvertUInt32(m_measurementMetadata.size()); | |
| 191 | 186 | const int64_t timestamp = ToTicks(UtcNow()); |
| 192 | 187 | vector<MeasurementPtr> measurements; |
| 193 | 188 | |