File tree 2 files changed +8
-4
lines changed
crates/pgt_workspace/src/workspace 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -372,7 +372,7 @@ impl Workspace for WorkspaceServer {
372
372
{
373
373
let path_clone = params. path . clone ( ) ;
374
374
let schema_cache = self . schema_cache . load ( pool. clone ( ) ) ?;
375
- let schema_cache_arc = Arc :: new ( schema_cache. as_ref ( ) . clone ( ) ) ;
375
+ let schema_cache_arc = schema_cache. get_arc ( ) ;
376
376
let input = parser. iter ( AsyncDiagnosticsMapper ) . collect :: < Vec < _ > > ( ) ;
377
377
// sorry for the ugly code :(
378
378
let async_results = run_async ( async move {
Original file line number Diff line number Diff line change 1
- use std:: sync:: { RwLock , RwLockReadGuard } ;
1
+ use std:: sync:: { Arc , RwLock , RwLockReadGuard } ;
2
2
3
3
use pgt_schema_cache:: SchemaCache ;
4
4
use sqlx:: PgPool ;
@@ -21,6 +21,10 @@ impl<'a> SchemaCacheHandle<'a> {
21
21
pub ( crate ) fn wrap ( inner : RwLockReadGuard < ' a , SchemaCacheManagerInner > ) -> Self {
22
22
Self { inner }
23
23
}
24
+
25
+ pub fn get_arc ( & self ) -> Arc < SchemaCache > {
26
+ Arc :: clone ( & self . inner . cache )
27
+ }
24
28
}
25
29
26
30
impl AsRef < SchemaCache > for SchemaCacheHandle < ' _ > {
@@ -31,7 +35,7 @@ impl AsRef<SchemaCache> for SchemaCacheHandle<'_> {
31
35
32
36
#[ derive( Default ) ]
33
37
pub ( crate ) struct SchemaCacheManagerInner {
34
- cache : SchemaCache ,
38
+ cache : Arc < SchemaCache > ,
35
39
conn_str : String ,
36
40
}
37
41
@@ -62,7 +66,7 @@ impl SchemaCacheManager {
62
66
63
67
// Double-check that we still need to refresh (another thread might have done it)
64
68
if new_conn_str != inner. conn_str {
65
- inner. cache = refreshed;
69
+ inner. cache = Arc :: new ( refreshed) ;
66
70
inner. conn_str = new_conn_str;
67
71
tracing:: info!( "Refreshed connection." ) ;
68
72
}
You can’t perform that action at this time.
0 commit comments