Skip to content

Commit 79399e0

Browse files
committed
手动刷新io
1 parent 013e30d commit 79399e0

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

CodeFormatServer/src/Session/IOSession.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ int IOSession::Run(asio::io_context& ioc)
2525
while(true)
2626
{
2727
ioc.run();
28-
std::this_thread::yield();
28+
std::this_thread::sleep_for(std::chrono::milliseconds(1));
2929
}
3030
});
3131
t.detach();
@@ -47,10 +47,10 @@ std::string IOSession::Handle(std::shared_ptr<ProtocolParser> parser)
4747
{
4848
return parser->SerializeProtocol(result);
4949
}
50-
std::cerr << format("request {}, it cost: {}ms\n", parser->GetMethod(),
51-
chrono::duration_cast<chrono::milliseconds>(
52-
chrono::system_clock::now() - start
53-
).count());
50+
// std::cerr << format("request {}, it cost: {}ms\n", parser->GetMethod(),
51+
// chrono::duration_cast<chrono::milliseconds>(
52+
// chrono::system_clock::now() - start
53+
// ).count());
5454
}
5555
}
5656
catch (std::exception& e)

CodeFormatServer/src/Session/StandardIOSession.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,16 @@ bool StandardIO::HasError()
7777
void StandardIO::Write(std::string_view content)
7878
{
7979
std::cout.write(content.data(), content.size());
80+
std::cout.flush();
8081
}
8182

8283
#endif
8384

8485

8586
int StandardIOSession::Run(asio::io_context& ioc)
8687
{
88+
// std::this_thread::sleep_for(std::chrono::seconds(15));
89+
IOSession::Run(ioc);
8790
while (true)
8891
{
8992
do

0 commit comments

Comments
 (0)