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