-
Notifications
You must be signed in to change notification settings - Fork 846
Add IReactorListener interface #9300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. | ||
|
|
||
| namespace FSharp.Compiler.SourceCodeServices | ||
|
|
||
| open System | ||
| open System.Diagnostics | ||
|
|
||
| type public IReactorListener = | ||
| abstract OnReactorPauseBeforeBackgroundWork : pauseMillis: int -> unit | ||
| abstract OnReactorOperationStart : userOpName: string -> opName: string -> opArg: string -> approxQueueLength: int -> unit | ||
| abstract OnReactorOperationEnd : userOpName: string -> opName: string -> elapsed: TimeSpan -> unit | ||
| abstract OnReactorBackgroundStart: bgUserOpName: string -> bgOpName: string -> bgOpArg: string -> unit | ||
| abstract OnReactorBackgroundCancelled : bgUserOpName: string -> bgOpName: string -> unit | ||
| abstract OnReactorBackgroundEnd : bgUserOpName: string -> bgOpName: string -> elapsed: TimeSpan -> unit | ||
|
|
||
| abstract OnSetBackgroundOp : approxQueueLength: int -> unit | ||
| abstract OnCancelBackgroundOp : unit -> unit | ||
| abstract OnEnqueueOp : userOpName: string -> opName: string -> opArg: string -> approxQueueLength: int -> unit | ||
|
|
||
| type public EmptyReactorListener() = | ||
| interface IReactorListener with | ||
| override __.OnReactorPauseBeforeBackgroundWork _ = () | ||
| override __.OnReactorOperationStart _ _ _ _ = () | ||
| override __.OnReactorOperationEnd _ _ _ = () | ||
| override __.OnReactorBackgroundStart _ _ _ = () | ||
| override __.OnReactorBackgroundCancelled _ _ = () | ||
| override __.OnReactorBackgroundEnd _ _ _ = () | ||
| override __.OnSetBackgroundOp _ = () | ||
| override __.OnCancelBackgroundOp () = () | ||
| override __.OnEnqueueOp _ _ _ _ = () | ||
|
|
||
| type public DefaultReactorListener() = | ||
| interface IReactorListener with | ||
| override __.OnReactorPauseBeforeBackgroundWork pauseMillis = | ||
| Trace.TraceInformation("Reactor: {0:n3} pausing {1} milliseconds", DateTime.Now.TimeOfDay.TotalSeconds, pauseMillis) | ||
| override __.OnReactorOperationStart userOpName opName opArg approxQueueLength = | ||
| Trace.TraceInformation("Reactor: {0:n3} --> {1}.{2} ({3}), remaining {4}", DateTime.Now.TimeOfDay.TotalSeconds, userOpName, opName, opArg, approxQueueLength) | ||
| override __.OnReactorOperationEnd userOpName opName elapsed = | ||
| let taken = elapsed.TotalMilliseconds | ||
| let msg = (if taken > 10000.0 then "BAD-OP: >10s " elif taken > 3000.0 then "BAD-OP: >3s " elif taken > 1000.0 then "BAD-OP: > 1s " elif taken > 500.0 then "BAD-OP: >0.5s " else "") | ||
| Trace.TraceInformation("Reactor: {0:n3} {1}<-- {2}.{3}, took {4} ms", DateTime.Now.TimeOfDay.TotalSeconds, msg, userOpName, opName, taken) | ||
| override __.OnReactorBackgroundStart bgUserOpName bgOpName bgOpArg = | ||
| Trace.TraceInformation("Reactor: {0:n3} --> background step {1}.{2} ({3})", DateTime.Now.TimeOfDay.TotalSeconds, bgUserOpName, bgOpName, bgOpArg) | ||
| override __.OnReactorBackgroundCancelled bgUserOpName bgOpName = | ||
| Trace.TraceInformation("FCS: <-- background step {0}.{1}, was cancelled", bgUserOpName, bgOpName) | ||
| override __.OnReactorBackgroundEnd _bgUserOpName _bgOpName elapsed = | ||
| let taken = elapsed.TotalMilliseconds | ||
| let msg = (if taken > 10000.0 then "BAD-BG-SLICE: >10s " elif taken > 3000.0 then "BAD-BG-SLICE: >3s " elif taken > 1000.0 then "BAD-BG-SLICE: > 1s " else "") | ||
| Trace.TraceInformation("Reactor: {0:n3} {1}<-- background step, took {2} ms", DateTime.Now.TimeOfDay.TotalSeconds, msg, taken) | ||
| override __.OnSetBackgroundOp approxQueueLength = | ||
| Trace.TraceInformation("Reactor: {0:n3} enqueue start background, length {1}", DateTime.Now.TimeOfDay.TotalSeconds, approxQueueLength) | ||
| override __.OnCancelBackgroundOp () = | ||
| Trace.TraceInformation("FCS: trying to cancel any active background work") | ||
| override __.OnEnqueueOp userOpName opName opArg approxQueueLength = | ||
| Trace.TraceInformation("Reactor: {0:n3} enqueue {1}.{2} ({3}), length {4}", DateTime.Now.TimeOfDay.TotalSeconds, userOpName, opName, opArg, approxQueueLength) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. | ||
|
|
||
| namespace FSharp.Compiler.SourceCodeServices | ||
|
|
||
| open System | ||
|
|
||
| /// Interface for listening to events on the FCS reactor thread. | ||
| type public IReactorListener = | ||
| /// Called when the reactor queue is empty, but there is background work to be done. | ||
| /// If no foreground work appears in the queue in the next <paramref name="pauseMillis"/> milliseconds, the background work will start. | ||
| /// Always called from the reactor thread. | ||
| abstract OnReactorPauseBeforeBackgroundWork : pauseMillis: int -> unit | ||
|
|
||
| /// Called when a foreground reactor operation starts. | ||
| /// Always called from the reactor thread. | ||
| abstract OnReactorOperationStart : userOpName: string -> opName: string -> opArg: string -> approxQueueLength: int -> unit | ||
|
|
||
| /// Called when a foreground reactor operation ends. | ||
| /// Always called from the reactor thread. | ||
| abstract OnReactorOperationEnd : userOpName: string -> opName: string -> elapsed: TimeSpan -> unit | ||
|
|
||
| /// Called when a background reactor operation starts. | ||
| /// Always called from the reactor thread. | ||
| abstract OnReactorBackgroundStart: bgUserOpName: string -> bgOpName: string -> bgOpArg: string -> unit | ||
|
|
||
| /// Called when a background operation is cancelled. | ||
| /// Always called from the reactor thread. | ||
| abstract OnReactorBackgroundCancelled : bgUserOpName: string -> bgOpName: string -> unit | ||
|
|
||
| /// Called when a background operation ends. | ||
| /// This is still called even if the operation was cancelled. | ||
| /// Always called from the reactor thread. | ||
| abstract OnReactorBackgroundEnd : bgUserOpName: string -> bgOpName: string -> elapsed: TimeSpan -> unit | ||
|
|
||
| /// Called when a background operation is set. | ||
| /// This can be called from ANY thread - implementations must be thread safe. | ||
| abstract OnSetBackgroundOp : approxQueueLength: int -> unit | ||
|
|
||
| /// Called when a background operation is requested to be cancelled. | ||
| /// This can be called from ANY thread - implementations must be thread safe. | ||
| abstract OnCancelBackgroundOp : unit -> unit | ||
|
|
||
| /// Called when an operation is queued to be ran on the reactor. | ||
| /// This can be called from ANY thread - implementations must be thread safe. | ||
| abstract OnEnqueueOp : userOpName: string -> opName: string -> opArg: string -> approxQueueLength: int -> unit | ||
|
|
||
| /// Reactor listener that does nothing. | ||
| /// Should be used as a base class for any implementers of IReactorListener. | ||
| [<Class>] | ||
| type public EmptyReactorListener = | ||
| new : unit -> EmptyReactorListener | ||
| interface IReactorListener | ||
|
|
||
| /// Default reactor listener. | ||
| /// Writes debug output using <see cref="System.Diagnostics.Trace" /> | ||
| [<Class>] | ||
| type public DefaultReactorListener = | ||
| new : unit -> DefaultReactorListener | ||
| interface IReactorListener |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is new code, can we consider using the single-underscore self identifier here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cartermp, I think fcs may use a bootstrap compiler thats pre- _.SomeMethod. I sort of half remember some issue due to fcs.