Commit 60646b8f authored by captainwong's avatar captainwong

update

parent 9e8edbdb
/**
Ping Pong Client
*/
#ifndef _WIN32 #ifndef _WIN32
#include <unistd.h> #include <unistd.h>
#include <netinet/in.h> #include <netinet/in.h>
...@@ -267,6 +263,8 @@ event_base* init_thread(const sockaddr_in& sin, int session_start, int session_p ...@@ -267,6 +263,8 @@ event_base* init_thread(const sockaddr_in& sin, int session_start, int session_p
fprintf(stderr, "error starting connection\n"); fprintf(stderr, "error starting connection\n");
exit(-1); exit(-1);
} }
std::this_thread::sleep_for(std::chrono::milliseconds(1));
} }
return base; return base;
...@@ -337,11 +335,11 @@ int main(int argc, char** argv) ...@@ -337,11 +335,11 @@ int main(int argc, char** argv)
std::vector<std::thread> threads; std::vector<std::thread> threads;
for (int i = 1; i < thread_count; i++) { for (int i = 1; i < thread_count; i++) {
auto base = init_thread(sin, i * session_per_thread, session_per_thread); threads.push_back(std::thread([&sin, i, session_per_thread]() {
threads.push_back(std::thread([](event_base* base) {
//printf("thread %lld created\n", gettid()); //printf("thread %lld created\n", gettid());
auto base = init_thread(sin, i * session_per_thread, session_per_thread);
event_base_dispatch(base); event_base_dispatch(base);
}, base)); }));
} }
auto main_thread_base = init_thread(sin, 0, session_per_thread); auto main_thread_base = init_thread(sin, 0, session_per_thread);
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerCommandArguments>192.168.1.168 12345 10 10</LocalDebuggerCommandArguments> <LocalDebuggerCommandArguments>192.168.1.166 12345 6 600 50</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup> </PropertyGroup>
</Project> </Project>
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
mkdir -p build mkdir -p build
cd build cd build
opt="-std=c++11 -O3" opt="-std=c++11 -O3 -g -gdwarf"
g++ $opt ../bench/bench.cpp -I../../include -o bench g++ $opt ../bench/bench.cpp -I../../include -o bench
g++ $opt ../demo/demo.cpp -I../../include -o demo g++ $opt ../demo/demo.cpp -I../../include -o demo
g++ $opt ../server_demo/server_demo.cpp -I../../include -lpthread -o server_demo g++ $opt ../server_demo/server_demo.cpp -I../../include -lpthread -o server_demo
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment