Skip to content

Commit 3ab08a5

Browse files
committed
More CR comments from Robert.
1 parent 0f86d9e commit 3ab08a5

File tree

3 files changed

+20
-22
lines changed

3 files changed

+20
-22
lines changed

Release/include/cpprest/details/basic_types.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ typedef uint32_t HRESULT; // Needed for PPLX
5050
typedef wchar_t char_t ;
5151
typedef std::wstring string_t;
5252
#define _XPLATSTR(x) L ## x
53-
#define _XPLATTOSTR(x) std::to_wstring(x)
53+
template<typename T>
54+
std::wstring to_tstring(const T& x) { return std::to_wstring(x); }
5455
typedef std::wostringstream ostringstream_t;
5556
typedef std::wofstream ofstream_t;
5657
typedef std::wostream ostream_t;
@@ -68,7 +69,8 @@ typedef std::wstringstream stringstream_t;
6869
typedef char char_t;
6970
typedef std::string string_t;
7071
#define _XPLATSTR(x) x
71-
#define _XPLATTOSTR(x) std::to_string(x)
72+
template<typename T>
73+
std::string to_tstring(const T& x) { return std::to_string(x); }
7274
typedef std::ostringstream ostringstream_t;
7375
typedef std::ofstream ofstream_t;
7476
typedef std::ostream ostream_t;

Release/libs/websocketpp/examples/broadcast_server/broadcast_server.cpp

+15-19
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ using websocketpp::lib::bind;
1919

2020
using websocketpp::lib::thread;
2121
using websocketpp::lib::mutex;
22-
using websocketpp::lib::lock_guard;
2322
using websocketpp::lib::unique_lock;
2423
using websocketpp::lib::condition_variable;
2524

@@ -72,30 +71,27 @@ class broadcast_server {
7271
}
7372

7473
void on_open(connection_hdl hdl) {
75-
{
76-
lock_guard<mutex> lock(m_action_lock);
77-
//std::cout << "on_open" << std::endl;
78-
m_actions.push(action(SUBSCRIBE,hdl));
79-
} // unlock
74+
unique_lock<mutex> lock(m_action_lock);
75+
//std::cout << "on_open" << std::endl;
76+
m_actions.push(action(SUBSCRIBE,hdl));
77+
lock.unlock();
8078
m_action_cond.notify_one();
8179
}
8280

8381
void on_close(connection_hdl hdl) {
84-
{
85-
lock_guard<mutex> lock(m_action_lock);
86-
//std::cout << "on_close" << std::endl;
87-
m_actions.push(action(UNSUBSCRIBE,hdl));
88-
} // unlock
82+
unique_lock<mutex> lock(m_action_lock);
83+
//std::cout << "on_close" << std::endl;
84+
m_actions.push(action(UNSUBSCRIBE,hdl));
85+
lock.unlock();
8986
m_action_cond.notify_one();
9087
}
9188

9289
void on_message(connection_hdl hdl, server::message_ptr msg) {
9390
// queue message up for sending by processing thread
94-
{
95-
lock_guard<mutex> lock(m_action_lock);
96-
//std::cout << "on_message" << std::endl;
97-
m_actions.push(action(MESSAGE,hdl,msg));
98-
} // unlock
91+
unique_lock<mutex> lock(m_action_lock);
92+
//std::cout << "on_message" << std::endl;
93+
m_actions.push(action(MESSAGE,hdl,msg));
94+
lock.unlock();
9995
m_action_cond.notify_one();
10096
}
10197

@@ -113,13 +109,13 @@ class broadcast_server {
113109
lock.unlock();
114110

115111
if (a.type == SUBSCRIBE) {
116-
lock_guard<mutex> con_lock(m_connection_lock);
112+
unique_lock<mutex> con_lock(m_connection_lock);
117113
m_connections.insert(a.hdl);
118114
} else if (a.type == UNSUBSCRIBE) {
119-
lock_guard<mutex> con_lock(m_connection_lock);
115+
unique_lock<mutex> con_lock(m_connection_lock);
120116
m_connections.erase(a.hdl);
121117
} else if (a.type == MESSAGE) {
122-
lock_guard<mutex> con_lock(m_connection_lock);
118+
unique_lock<mutex> con_lock(m_connection_lock);
123119

124120
con_list::iterator it;
125121
for (it = m_connections.begin(); it != m_connections.end(); ++it) {

Release/src/http/client/http_client_winhttp.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ class winhttp_client final : public _http_client_communicator
490490
if (uri.port() > 0)
491491
{
492492
proxy_str.push_back(_XPLATSTR(':'));
493-
proxy_str.append(_XPLATTOSTR(uri.port()));
493+
proxy_str.append(utility::to_tstring(uri.port()));
494494
}
495495

496496
proxy_name = proxy_str.c_str();

0 commit comments

Comments
 (0)