Commit 60646b8f authored by captainwong's avatar captainwong

update

parent 9e8edbdb
/**
Ping Pong Client
*/
#ifndef _WIN32
#include <unistd.h>
#include <netinet/in.h>
......@@ -267,6 +263,8 @@ event_base* init_thread(const sockaddr_in& sin, int session_start, int session_p
fprintf(stderr, "error starting connection\n");
exit(-1);
}
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
return base;
......@@ -336,12 +334,12 @@ int main(int argc, char** argv)
std::vector<std::thread> threads;
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([](event_base* base) {
for (int i = 1; i < thread_count; i++) {
threads.push_back(std::thread([&sin, i, session_per_thread]() {
//printf("thread %lld created\n", gettid());
event_base_dispatch(base);
}, base));
auto base = init_thread(sin, i * session_per_thread, session_per_thread);
event_base_dispatch(base);
}));
}
auto main_thread_base = init_thread(sin, 0, session_per_thread);
......
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<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>
</PropertyGroup>
</Project>
\ No newline at end of file
......@@ -2,7 +2,7 @@
mkdir -p 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 ../demo/demo.cpp -I../../include -o 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