Support #7323 ยป broadcast_example_issue_7323.patch
examples/feature/broadcast/BroadCast.C | ||
---|---|---|
assert(false);
|
||
}
|
||
int getCount() const {
|
||
double getCount() const {
|
||
std::unique_lock<std::mutex> lock(mutex_);
|
||
return counter_;
|
||
... | ... | |
mutable std::mutex mutex_;
|
||
std::thread thread_;
|
||
int counter_;
|
||
double counter_;
|
||
bool stop_;
|
||
std::vector<Connection> connections_;
|
||
... | ... | |
* thread.
|
||
*/
|
||
for (;;) {
|
||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||
std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
||
if (stop_)
|
||
return;
|
||
{
|
||
std::unique_lock<std::mutex> lock(mutex_);
|
||
++counter_;
|
||
if (counter_++ > 10000)
|
||
counter_ = 0;
|
||
/* This is where we notify all connected clients. */
|
||
for (unsigned i = 0; i < connections_.size(); ++i) {
|
||
Connection& c = connections_[i];
|
||
WServer::instance()->post(c.sessionId, c.function);
|
||
for (auto& c: connections_) {
|
||
Wt::WServer::instance()->post(c.sessionId, c.function);
|
||
}
|
||
}
|
||
}
|