提交 91af6e8d 编写于 作者: W Will Smith

Removing reactor changes

上级 ffcbdea4
......@@ -43,17 +43,6 @@ type Reactor() =
let mutable bgOpCts = new CancellationTokenSource()
let threadsUsed = System.Collections.Concurrent.ConcurrentDictionary<int, byte>()
let useThread (thread: Thread) =
thread.CurrentUICulture <- culture
threadsUsed.[thread.ManagedThreadId] <- 0uy
{ new IDisposable with
member _.Dispose() =
let res, _ = threadsUsed.TryRemove(thread.ManagedThreadId)
assert res
}
/// Mailbox dispatch function.
let builder =
MailboxProcessor<_>.Start <| fun inbox ->
......@@ -80,9 +69,7 @@ type Reactor() =
Trace.TraceInformation("Reactor: {0:n3} pausing {1} milliseconds", DateTime.Now.TimeOfDay.TotalSeconds, pauseBeforeBackgroundWork)
pauseBeforeBackgroundWork
return! inbox.TryReceive(timeout) }
use _disposable = useThread Thread.CurrentThread
Thread.CurrentThread.CurrentUICulture <- culture
match msg with
| Some (SetBackgroundOp bgOpOpt) ->
//Trace.TraceInformation("Reactor: --> set background op, remaining {0}", inbox.CurrentQueueLength)
......@@ -211,18 +198,6 @@ type Reactor() =
return! resultCell.AsyncResult
}
member r.ExecuteOrEnqueueAndAwaitOpAsync (userOpName, opName, opArg, f) =
if threadsUsed.ContainsKey(Thread.CurrentThread.ManagedThreadId) then
async {
let! ct = Async.CancellationToken
let result =
match Cancellable.run ct (f (AssumeCompilationThreadWithoutEvidence())) with
| ValueOrCancelled.Value r -> r
| ValueOrCancelled.Cancelled e -> raise e
return result }
else
r.EnqueueAndAwaitOpAsync(userOpName, opName, opArg, f)
member __.PauseBeforeBackgroundWork with get() = pauseBeforeBackgroundWork and set v = pauseBeforeBackgroundWork <- v
static member Singleton = theReactor
......
......@@ -48,10 +48,6 @@ type internal Reactor =
/// Put the operation in the queue, and return an async handle to its result.
member EnqueueAndAwaitOpAsync : userOpName:string * opName:string * opArg:string * (CompilationThreadToken -> Cancellable<'T>) -> Async<'T>
/// Put the operation in the queue or run it immediately if the op is trying to be executed on the thread that is currently being used in the reactor.
/// This prevents a deadlock.
member ExecuteOrEnqueueAndAwaitOpAsync : userOpName:string * opName:string * opArg:string * (CompilationThreadToken -> Cancellable<'T>) -> Async<'T>
/// The timespan in milliseconds before background work begins after the operations queue is empty
member PauseBeforeBackgroundWork : int with get, set
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册