@@ -27,26 +27,22 @@ type AsyncHandler struct {
27
27
func (ah AsyncHandler ) Handle (ctx context.Context , conn * jsonrpc2.Conn , req * jsonrpc2.Request ) {
28
28
needsWriteLock := req .Method == "textDocument/didOpen" || req .Method == "textDocument/didChange"
29
29
if needsWriteLock {
30
- ah .synchronizer .FileMux .Lock ()
31
- if enableLogging {
32
- log .Println ("Message processing locked for" , req .Method )
33
- }
34
- go ah .runWrite (ctx , conn , req )
30
+ go func () {
31
+ ah .synchronizer .FileMux .Lock ()
32
+ defer ah .synchronizer .FileMux .Unlock ()
33
+ if enableLogging {
34
+ log .Println ("Message processing locked for" , req .Method )
35
+ }
36
+ ah .handler .Handle (ctx , conn , req )
37
+ if enableLogging {
38
+ log .Println ("Message processing unlocked for" , req .Method )
39
+ }
40
+ }()
35
41
} else {
36
- ah .synchronizer .FileMux .RLock ()
37
- go ah .runRead (ctx , conn , req )
38
- }
39
- }
40
-
41
- func (ah AsyncHandler ) runRead (ctx context.Context , conn * jsonrpc2.Conn , req * jsonrpc2.Request ) {
42
- defer ah .synchronizer .FileMux .RUnlock ()
43
- ah .handler .Handle (ctx , conn , req )
44
- }
45
-
46
- func (ah AsyncHandler ) runWrite (ctx context.Context , conn * jsonrpc2.Conn , req * jsonrpc2.Request ) {
47
- defer ah .synchronizer .FileMux .Unlock ()
48
- ah .handler .Handle (ctx , conn , req )
49
- if enableLogging {
50
- log .Println ("Message processing unlocked for" , req .Method )
42
+ go func () {
43
+ ah .synchronizer .FileMux .RLock ()
44
+ ah .handler .Handle (ctx , conn , req )
45
+ ah .synchronizer .FileMux .RUnlock ()
46
+ }()
51
47
}
52
48
}
0 commit comments