Skip to content

Commit 6f87d29

Browse files
authored
refactor(server): try async
1 parent 40045e3 commit 6f87d29

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

crates/server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ exclude = ["/tests"]
1212
[dependencies]
1313
anyhow = "1.0"
1414
async-lock = "3.4"
15-
compio = { version = "0.13", features = ["arrayvec"] }
15+
compio = { version = "0.13", features = ["arrayvec"], git = "https://github.com/compio-rs/compio.git" }
1616
lsp-types.workspace = true
1717
rustc-hash.workspace = true
1818
serde.workspace = true

crates/server/src/server.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,12 @@ impl Server {
6565
let stdio = self.stdio.clone();
6666
let runtime = Arc::clone(&runtime);
6767
async move {
68-
runtime
69-
.spawn_blocking(|| {
70-
// TODO: handle request here once compio released new version
68+
if let Ok(Some(message)) = runtime
69+
.spawn_blocking(move || {
70+
Self::handle_request(service, id, method, params)
7171
})
7272
.await
73-
.expect("failed to handle request");
74-
if let Ok(Some(message)) =
75-
Self::handle_request(service, id, method, params).await
73+
.unwrap()
7674
{
7775
stdio.write(message).await?;
7876
}
@@ -162,7 +160,7 @@ impl Server {
162160
Ok(())
163161
}
164162

165-
async fn handle_request(
163+
fn handle_request(
166164
service: impl Deref<Target = LanguageService>,
167165
id: u32,
168166
method: String,

crates/service/src/features/diagnostics.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ impl LanguageService {
1111
&self,
1212
params: DocumentDiagnosticParams,
1313
) -> DocumentDiagnosticReportResult {
14+
// imagine that checker is very slow
15+
std::thread::sleep(std::time::Duration::from_secs(7));
1416
let diagnostics = checker::check(self, self.uri(params.text_document.uri));
1517
DocumentDiagnosticReportResult::Report(DocumentDiagnosticReport::Full(
1618
RelatedFullDocumentDiagnosticReport {

0 commit comments

Comments
 (0)