Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono-addins.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLluis Sanchez <llsan@microsoft.com>2022-10-06 13:59:24 +0300
committerGitHub <noreply@github.com>2022-10-06 13:59:24 +0300
commit9269dca26784bc7c8286b1c034a71edaafd67f86 (patch)
treeba93f663fd353b8ea2bd563c826d7e26970bc031 /Mono.Addins/Mono.Addins/InstanceExtensionNode.cs
parent85b194814d9630f17b98c2c713e603cb9695cab3 (diff)
parent186642cdb5a3d6938cb693b4900db67ee5dca83c (diff)
Merge pull request #187 from mono/dev/lluis/threadsafe
Make mono.addins thread safe
Diffstat (limited to 'Mono.Addins/Mono.Addins/InstanceExtensionNode.cs')
-rw-r--r--Mono.Addins/Mono.Addins/InstanceExtensionNode.cs9
1 files changed, 7 insertions, 2 deletions
diff --git a/Mono.Addins/Mono.Addins/InstanceExtensionNode.cs b/Mono.Addins/Mono.Addins/InstanceExtensionNode.cs
index 3d6640d..37e2791 100644
--- a/Mono.Addins/Mono.Addins/InstanceExtensionNode.cs
+++ b/Mono.Addins/Mono.Addins/InstanceExtensionNode.cs
@@ -69,8 +69,13 @@ namespace Mono.Addins
/// </remarks>
public object GetInstance ()
{
- if (cachedInstance == null)
- cachedInstance = CreateInstance ();
+ if (cachedInstance == null) {
+ lock (localLock) {
+ // Use locking here to avoid creating more than one instance per ExtensionNode
+ if (cachedInstance == null)
+ cachedInstance = CreateInstance ();
+ }
+ }
return cachedInstance;
}