mirror of
https://github.com/godotengine/godot.git
synced 2025-10-20 08:23:29 +00:00
Allow LSP to process multiple messages per poll
(cherry-picked from commit e2485044a1
)
This commit is contained in:
parent
3f1caf6640
commit
38b646ca4a
4 changed files with 25 additions and 12 deletions
|
@ -103,7 +103,7 @@ Error GDScriptLanguageProtocol::LSPeer::handle_data() {
|
|||
|
||||
Error GDScriptLanguageProtocol::LSPeer::send_data() {
|
||||
int sent = 0;
|
||||
if (!res_queue.empty()) {
|
||||
while (!res_queue.empty()) {
|
||||
CharString c_res = res_queue[0];
|
||||
if (res_sent < c_res.size()) {
|
||||
Error err = connection->put_partial_data((const uint8_t *)c_res.get_data() + res_sent, c_res.size() - res_sent - 1, sent);
|
||||
|
@ -227,7 +227,9 @@ void GDScriptLanguageProtocol::initialized(const Variant &p_params) {
|
|||
notify_client("gdscript/capabilities", capabilities.to_json());
|
||||
}
|
||||
|
||||
void GDScriptLanguageProtocol::poll() {
|
||||
void GDScriptLanguageProtocol::poll(int p_limit_usec) {
|
||||
uint64_t target_ticks = OS::get_singleton()->get_ticks_usec() + p_limit_usec;
|
||||
|
||||
if (server->is_connection_available()) {
|
||||
on_client_connected();
|
||||
}
|
||||
|
@ -239,15 +241,22 @@ void GDScriptLanguageProtocol::poll() {
|
|||
on_client_disconnected(*id);
|
||||
id = nullptr;
|
||||
} else {
|
||||
if (peer->connection->get_available_bytes() > 0) {
|
||||
Error err = OK;
|
||||
while (peer->connection->get_available_bytes() > 0) {
|
||||
latest_client_id = *id;
|
||||
Error err = peer->handle_data();
|
||||
if (err != OK && err != ERR_BUSY) {
|
||||
on_client_disconnected(*id);
|
||||
id = nullptr;
|
||||
err = peer->handle_data();
|
||||
if (err != OK || OS::get_singleton()->get_ticks_usec() >= target_ticks) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Error err = peer->send_data();
|
||||
|
||||
if (err != OK && err != ERR_BUSY) {
|
||||
on_client_disconnected(*id);
|
||||
id = nullptr;
|
||||
continue;
|
||||
}
|
||||
|
||||
err = peer->send_data();
|
||||
if (err != OK && err != ERR_BUSY) {
|
||||
on_client_disconnected(*id);
|
||||
id = nullptr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue