-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Various micro perf fixes and cleanup found while implementing CN overrides so far #818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
fd06a69
ccf8e16
f1a1678
0c16592
a36e368
0ff6d4a
719e40d
34d85cf
3d9b3f8
6a55deb
0f86d9e
3ab08a5
beb660c
6788781
12ea5ce
cc9daf0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ using websocketpp::lib::bind; | |
|
||
using websocketpp::lib::thread; | ||
using websocketpp::lib::mutex; | ||
using websocketpp::lib::unique_lock; | ||
using websocketpp::lib::lock_guard; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is part of the vendored copy of websocketpp, so we should avoid modifying it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, I'll revert changes in this example. |
||
using websocketpp::lib::condition_variable; | ||
|
||
/* on_open insert connection_hdl into channel | ||
|
@@ -71,15 +71,15 @@ class broadcast_server { | |
} | ||
|
||
void on_open(connection_hdl hdl) { | ||
unique_lock<mutex> lock(m_action_lock); | ||
lock_guard<mutex> lock(m_action_lock); | ||
//std::cout << "on_open" << std::endl; | ||
m_actions.push(action(SUBSCRIBE,hdl)); | ||
lock.unlock(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm apparently this isn't built? |
||
m_action_cond.notify_one(); | ||
} | ||
|
||
void on_close(connection_hdl hdl) { | ||
unique_lock<mutex> lock(m_action_lock); | ||
lock_guard<mutex> lock(m_action_lock); | ||
//std::cout << "on_close" << std::endl; | ||
m_actions.push(action(UNSUBSCRIBE,hdl)); | ||
lock.unlock(); | ||
|
@@ -88,7 +88,7 @@ class broadcast_server { | |
|
||
void on_message(connection_hdl hdl, server::message_ptr msg) { | ||
// queue message up for sending by processing thread | ||
unique_lock<mutex> lock(m_action_lock); | ||
lock_guard<mutex> lock(m_action_lock); | ||
//std::cout << "on_message" << std::endl; | ||
m_actions.push(action(MESSAGE,hdl,msg)); | ||
lock.unlock(); | ||
|
@@ -97,7 +97,7 @@ class broadcast_server { | |
|
||
void process_messages() { | ||
while(1) { | ||
unique_lock<mutex> lock(m_action_lock); | ||
lock_guard<mutex> lock(m_action_lock); | ||
|
||
while(m_actions.empty()) { | ||
m_action_cond.wait(lock); | ||
|
@@ -109,13 +109,13 @@ class broadcast_server { | |
lock.unlock(); | ||
|
||
if (a.type == SUBSCRIBE) { | ||
unique_lock<mutex> con_lock(m_connection_lock); | ||
lock_guard<mutex> con_lock(m_connection_lock); | ||
m_connections.insert(a.hdl); | ||
} else if (a.type == UNSUBSCRIBE) { | ||
unique_lock<mutex> con_lock(m_connection_lock); | ||
lock_guard<mutex> con_lock(m_connection_lock); | ||
m_connections.erase(a.hdl); | ||
} else if (a.type == MESSAGE) { | ||
unique_lock<mutex> con_lock(m_connection_lock); | ||
lock_guard<mutex> con_lock(m_connection_lock); | ||
|
||
con_list::iterator it; | ||
for (it = m_connections.begin(); it != m_connections.end(); ++it) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps it makes more sense to define a
template<class T> string_t to_string_t(T&&)
?