Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2ee41c6

Browse files
fix the semaphore
1 parent45c4026 commit2ee41c6

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

‎vsintegration/src/FSharp.Editor/Common/CommonHelpers.fs‎

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ module internal Extensions =
385385
openSystem
386386
openSystem.IO
387387
openMicrosoft.FSharp.Compiler.Ast
388+
openMicrosoft.VisualStudio.FSharp.Editor.Logging
388389

389390
typeSystem.IServiceProviderwith
390391
memberx.GetService<'T>()= x.GetService(typeof<'T>):?> 'T
@@ -416,26 +417,37 @@ module internal Extensions =
416417
}
417418

418419
memberthis.ParseAndCheckDocument(filePath:string,textVersionHash:int,sourceText:string,options:FSharpProjectOptions,allowStaleResults:bool):Async<(FSharpParseFileResults* Ast.ParsedInput* FSharpCheckFileResults)option>=
420+
letlog=
421+
letfile= Path.GetFileName filePath
422+
Printf.kprintf(fun s-> Logging.logInfof"[ParseAndCheckDocument(%s)]%s" file s)
419423
async{
424+
use ready=new SemaphoreSlim(0)
420425
let!freshResults=
421426
async{
422-
use ready=new SemaphoreSlim(1)
423427
let!worker=
424428
async{
429+
log"--> ParseAndCheckFileInProject"
425430
let!parseResults,checkFileAnswer= this.ParseAndCheckFileInProject(filePath, textVersionHash, sourceText, options)
431+
log"<-- ParseAndCheckFileInProject"
426432
letresult=
427433
match checkFileAnswerwith
428434
| FSharpCheckFileAnswer.Aborted->
429435
None
430436
| FSharpCheckFileAnswer.Succeeded(checkFileResults)->
431437
Some(parseResults, checkFileResults)
432438
ready.Release()|> ignore
439+
log"`ready` released"
433440
return result
434-
}|> Async.StartChildAsTask
441+
}|> Async.StartChild
442+
log"waiting for result for 2 seconds"
435443
let!gotResult= ready.WaitAsync(TimeSpan.FromSeconds2.)|> Async.AwaitTask
436-
if gotResultthen
437-
return Ready worker.Result
438-
elsereturn StillRunning(Async.AwaitTask worker)
444+
if gotResultthen
445+
log"got result in 2 seconds"
446+
let!result= worker
447+
return Ready result
448+
else
449+
log"DID NOT get result in 2 seconds"
450+
return StillRunning worker
439451
}
440452

441453
let!results=
@@ -445,8 +457,10 @@ module internal Extensions =
445457
async{
446458
match allowStaleResults, this.TryGetRecentCheckResultsForFile(filePath, options)with
447459
|true, Some(parseResults, checkFileResults,_)->
460+
log"returning stale results"
448461
return Some(parseResults, checkFileResults)
449462
|_->
463+
log"stale results cannot be returned, waiting for `worker` to complete"
450464
return! worker
451465
}
452466

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp