From e28d09469fb4a66119c690526e226bf8cb021e6a Mon Sep 17 00:00:00 2001 From: Eli Belash Date: Fri, 30 Aug 2019 19:35:23 +0300 Subject: [PATCH] Create Locks.cs --- src/TensorFlowNET.Core/Util/Locks.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/TensorFlowNET.Core/Util/Locks.cs diff --git a/src/TensorFlowNET.Core/Util/Locks.cs b/src/TensorFlowNET.Core/Util/Locks.cs new file mode 100644 index 00000000..3b54ee2c --- /dev/null +++ b/src/TensorFlowNET.Core/Util/Locks.cs @@ -0,0 +1,21 @@ +using System.Threading; + +namespace Tensorflow.Util +{ + /// + /// Provides a set of locks on different shared levels. + /// + public static class Locks + { + private static readonly ThreadLocal _lockpool = new ThreadLocal(() => new object()); + + /// + /// A seperate lock for every requesting thread. + /// + /// This property is thread-safe. + public static object ThreadWide => _lockpool.Value; + + + public static readonly object ProcessWide = new object(); + } +} \ No newline at end of file