History

TimeSeriesPlatformLibrary: Simplfied data publisher threading implementations.

J. Ritchie Carroll committed 7 years ago

Commit 68c05e01 parent aea1d009 files · +219 −232Browse files

Showing the changes to Source/Libraries/TimeSeriesPlatformLibrary/Samples/InstancePublish.cpp (1 of 9 files). Show all

Unified · Split

Source/Libraries/TimeSeriesPlatformLibrary/Samples/InstancePublish.cpp+9−11
@@ -35,7 +35,6 @@ PublisherHandler* Publisher[TotalInstances]; · 34 unmodified lines
35 35
36int main(int argc, char* argv[])36int main(int argc, char* argv[])
37{37{
38 string hostname;
39 uint16_t port;38 uint16_t port;
40 39
41 // Ensure that the necessary40 // Ensure that the necessary
@@ -56,28 +55,27 @@ int main(int argc, char* argv[]) · 14 unmodified lines
56 // Maintain the life-time of PublisherHandler instances within main55 // Maintain the life-time of PublisherHandler instances within main
57 PublisherHandler* publisher = new PublisherHandler("Publisher " + ToString(i + 1), port + i, false);56 PublisherHandler* publisher = new PublisherHandler("Publisher " + ToString(i + 1), port + i, false);
58 57
59 // Set second publisher to only allow one connection58 // Set second publisher to only allow one connection
60 if (i == 1)59 if (i == 1)
61 publisher->SetMaximumAllowedConnections(1);60 publisher->SetMaximumAllowedConnections(1);
62 61
63 publisher->Start();62 publisher->Start();
64 Publisher[i] = publisher;63 Publisher[i] = publisher;
65 }64 }
66 65
67 // Wait until the user presses enter before quitting.66 // Wait until the user presses enter before quitting.
68 string line;67 string line;
69 getline(cin, line);68 getline(cin, line);
70 69
71 // Shutdown publisher instances70 // Stop publisher instances - this stops publication
72 for (uint32_t i = 0; i < TotalInstances; i++)71 for (uint32_t i = 0; i < TotalInstances; i++)
73 Publisher[i]->Stop();72 Publisher[i]->Stop();
74 73
75 // Disconnect the publisher to stop background threads.74 // Delete publisher instances - this closes sockets
76 cout << "Disconnected." << endl;
77
78 // Delete publisher instances
79 for (uint32_t i = 0; i < TotalInstances; i++)75 for (uint32_t i = 0; i < TotalInstances; i++)
80 delete Publisher[i];76 delete Publisher[i];
81 77
78 cout << "Publishers stopped." << endl;
79
82 return 0;80 return 0;
83}81}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t