-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Various micro perf fixes and cleanup found while implementing CN overrides so far #818
Merged
Merged
Changes from 11 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
fd06a69
Microperf: Use lock_guard instead of unique_lock.
BillyONeal ccf8e16
Bill hates lock_guard more.
BillyONeal f1a1678
Ref them connections.
BillyONeal 0c16592
Demacroize.
BillyONeal a36e368
Commonize port and merge some CRLFs into adjacent string literals.
BillyONeal 0ff6d4a
Add missing template keyword.
BillyONeal 719e40d
Avoid stringstream in constructing the proxy_str.
BillyONeal 34d85cf
Remove unused forward declarations of some HTTP things.
BillyONeal 3d9b3f8
Use NOMINMAX instead of undef min and max everywhere.
BillyONeal 6a55deb
Bunch of inheritance hygiene.
BillyONeal 0f86d9e
What do you mean you want examples to compile?
BillyONeal 3ab08a5
More CR comments from Robert.
BillyONeal beb660c
Add static.
BillyONeal 6788781
Use existing to_string_t.
BillyONeal 12ea5ce
Merge remote-tracking branch 'upstream/master' into perf_fixes
BillyONeal cc9daf0
Merge remote-tracking branch 'upstream/master' into perf_fixes
BillyONeal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ using websocketpp::lib::bind; | |
|
||
using websocketpp::lib::thread; | ||
using websocketpp::lib::mutex; | ||
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::unique_lock; | ||
using websocketpp::lib::condition_variable; | ||
|
||
|
@@ -71,27 +72,30 @@ class broadcast_server { | |
} | ||
|
||
void on_open(connection_hdl hdl) { | ||
unique_lock<mutex> lock(m_action_lock); | ||
//std::cout << "on_open" << std::endl; | ||
m_actions.push(action(SUBSCRIBE,hdl)); | ||
lock.unlock(); | ||
{ | ||
lock_guard<mutex> lock(m_action_lock); | ||
//std::cout << "on_open" << std::endl; | ||
m_actions.push(action(SUBSCRIBE,hdl)); | ||
} // unlock | ||
m_action_cond.notify_one(); | ||
} | ||
|
||
void on_close(connection_hdl hdl) { | ||
unique_lock<mutex> lock(m_action_lock); | ||
//std::cout << "on_close" << std::endl; | ||
m_actions.push(action(UNSUBSCRIBE,hdl)); | ||
lock.unlock(); | ||
{ | ||
lock_guard<mutex> lock(m_action_lock); | ||
//std::cout << "on_close" << std::endl; | ||
m_actions.push(action(UNSUBSCRIBE,hdl)); | ||
} // unlock | ||
m_action_cond.notify_one(); | ||
} | ||
|
||
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); | ||
//std::cout << "on_message" << std::endl; | ||
m_actions.push(action(MESSAGE,hdl,msg)); | ||
lock.unlock(); | ||
{ | ||
lock_guard<mutex> lock(m_action_lock); | ||
//std::cout << "on_message" << std::endl; | ||
m_actions.push(action(MESSAGE,hdl,msg)); | ||
} // unlock | ||
m_action_cond.notify_one(); | ||
} | ||
|
||
|
@@ -109,13 +113,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) { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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&&)
?