提交 08c32bc9 编写于 作者: W Will Smith

Lock per TP instance

上级 91af6e8d
......@@ -707,11 +707,7 @@ type TcImportsSafeDisposal
if verbose then
dprintf "disposing of TcImports, %d binaries\n" disposeActions.Count
#if !NO_EXTENSIONTYPING
async {
let actions = disposeTypeProviderActions
if actions.Count > 0 then
TypeProviderLock.Singleton.AcquireLock(fun _ -> for action in actions do action())
} |> Async.Start // Make this async so we do not block dispose
for action in disposeTypeProviderActions do action()
#endif
for action in disposeActions do action()
......@@ -1258,7 +1254,7 @@ and [<Sealed>] TcImports(tcConfigP: TcConfigProvider, initialResolutions: TcAsse
for provider in providers do
tcImportsStrong.AttachDisposeTypeProviderAction(fun () ->
try
provider.PUntaintNoFailure(fun x -> x).Dispose()
provider.PUntaintNoFailure(fun x -> x.Dispose())
with e ->
())
......
......@@ -97,7 +97,7 @@ module internal ExtensionTyping =
// reporting errors.
let protect f =
try
TypeProviderLock.Singleton.AcquireLock(fun _ -> f ())
f ()
with err ->
let e = StripException (StripException err)
raise (TypeProviderError(FSComp.SR.etTypeProviderConstructorException(e.Message), typeProviderImplementationType.FullName, m))
......
......@@ -17,8 +17,6 @@ type internal TypeProviderToken() = interface LockToken
type internal TypeProviderLock() =
inherit Lock<TypeProviderToken>()
static member val Singleton = TypeProviderLock()
type internal TypeProviderError
(
errNum : int,
......@@ -78,7 +76,7 @@ type internal TypeProviderError
for msg in errors do
f (new TypeProviderError(errNum, tpDesignation, m, [msg], typeNameContext, methodNameContext))
type TaintedContext = { TypeProvider : ITypeProvider; TypeProviderAssemblyRef : ILScopeRef }
type TaintedContext = { TypeProvider : ITypeProvider; TypeProviderAssemblyRef : ILScopeRef; Lock: TypeProviderLock }
[<NoEquality>][<NoComparison>]
type internal Tainted<'T> (context : TaintedContext, value : 'T) =
......@@ -97,7 +95,7 @@ type internal Tainted<'T> (context : TaintedContext, value : 'T) =
member this.Protect f (range:range) =
try
TypeProviderLock.Singleton.AcquireLock(fun _ -> f value)
context.Lock.AcquireLock(fun _ -> f value)
with
| :? TypeProviderError -> reraise()
| :? AggregateException as ae ->
......@@ -152,7 +150,7 @@ type internal Tainted<'T> (context : TaintedContext, value : 'T) =
static member CreateAll(providerSpecs : (ITypeProvider * ILScopeRef) list) =
[for (tp,nm) in providerSpecs do
yield Tainted<_>({ TypeProvider=tp; TypeProviderAssemblyRef=nm },tp) ]
yield Tainted<_>({ TypeProvider=tp; TypeProviderAssemblyRef=nm; Lock=TypeProviderLock() },tp) ]
member this.OfType<'U> () =
match box value with
......
......@@ -20,8 +20,6 @@ type internal TypeProviderToken =
type internal TypeProviderLock =
inherit Lock<TypeProviderToken>
static member Singleton : TypeProviderLock
/// Stores and transports aggregated list of errors reported by the type provider
type internal TypeProviderError =
inherit System.Exception
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册