add gc request

This commit is contained in:
Aleksey Kladov 2019-01-25 19:11:58 +03:00
parent 6df1f71b7d
commit f6adb85b68
7 changed files with 44 additions and 11 deletions

View file

@ -205,17 +205,26 @@ fn main_loop_inner(
Some(req) => req,
None => return Ok(()),
};
match on_request(state, pending_requests, pool, &task_sender, req)? {
None => (),
Some(req) => {
log::error!("unknown request: {:?}", req);
let resp = RawResponse::err(
req.id,
ErrorCode::MethodNotFound as i32,
"unknown request".to_string(),
);
match req.cast::<req::CollectGarbage>() {
Ok((id, ())) => {
state.collect_garbadge();
let resp = RawResponse::ok::<req::CollectGarbage>(id, &());
msg_sender.send(RawMessage::Response(resp)).unwrap()
}
Err(req) => {
match on_request(state, pending_requests, pool, &task_sender, req)? {
None => (),
Some(req) => {
log::error!("unknown request: {:?}", req);
let resp = RawResponse::err(
req.id,
ErrorCode::MethodNotFound as i32,
"unknown request".to_string(),
);
msg_sender.send(RawMessage::Response(resp)).unwrap()
}
}
}
}
}
RawMessage::Notification(not) => {

View file

@ -19,6 +19,14 @@ impl Request for AnalyzerStatus {
const METHOD: &'static str = "ra/analyzerStatus";
}
pub enum CollectGarbage {}
impl Request for CollectGarbage {
type Params = ();
type Result = ();
const METHOD: &'static str = "ra/collectGarbage";
}
pub enum SyntaxTree {}
impl Request for SyntaxTree {

View file

@ -231,6 +231,10 @@ impl ServerWorldState {
vfs: Arc::clone(&self.vfs),
}
}
pub fn collect_garbadge(&mut self) {
self.analysis_host.collect_garbage()
}
}
impl ServerWorld {