File tree Expand file tree Collapse file tree 3 files changed +25
-3
lines changed
CodeFormatServer/src/Session
include/CodeFormatServer/Session Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -18,12 +18,19 @@ IOSession::~IOSession()
1818{
1919 if (_logicThread)
2020 {
21+ #ifndef __APPLE__
2122 _logicThread->request_stop ();
23+ #else
24+ _running = false ;
25+ _logicThread->join ();
26+ #endif
2227 }
2328}
2429
2530int IOSession::Run (asio::io_context& ioc)
2631{
32+ // Æ»¹ûÔÝδ֧³Ö Õâ¸öjthread
33+ #ifndef __APPLE__
2734 _logicThread = std::make_shared<std::jthread>([&ioc](std::stop_token st)
2835 {
2936 while (!st.stop_requested ())
@@ -33,6 +40,17 @@ int IOSession::Run(asio::io_context& ioc)
3340 std::this_thread::sleep_for (std::chrono::milliseconds (1 ));
3441 }
3542 });
43+ #else
44+ _logicThread = std::make_shared<std::thread>([&ioc, this ]()
45+ {
46+ while (_running)
47+ {
48+ ioc.run ();
49+ ioc.reset ();
50+ std::this_thread::sleep_for (std::chrono::milliseconds (1 ));
51+ }
52+ });
53+ #endif
3654
3755 return 0 ;
3856}
Original file line number Diff line number Diff line change 1- #pragma once
2-
3- #include " LuaParser/LuaIdentify.h"
1+ #include " LuaParser/LuaIdentify.h"
42#include " LuaDefine.h"
53
64std::array<unsigned char , UCHAR_MAX + 2 > LuaIdentify::LuaCharType = {
Original file line number Diff line number Diff line change @@ -19,5 +19,11 @@ class IOSession
1919 ProtocolBuffer _protocolBuffer;
2020private:
2121 LanguageService _service;
22+ #ifndef __APPLE__
2223 std::shared_ptr<std::jthread> _logicThread;
24+ #else
25+ std::shared_ptr<std::thread> _logicThread = nullptr ;
26+ volatile bool _running = true ;
27+ #endif
28+
2329};
You can’t perform that action at this time.
0 commit comments