Skip to content

Commit e28d094

Browse files
committed
Create Locks.cs
1 parent e56164d commit e28d094

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.Threading;
2+
3+
namespace Tensorflow.Util
4+
{
5+
/// <summary>
6+
/// Provides a set of locks on different shared levels.
7+
/// </summary>
8+
public static class Locks
9+
{
10+
private static readonly ThreadLocal<object> _lockpool = new ThreadLocal<object>(() => new object());
11+
12+
/// <summary>
13+
/// A seperate lock for every requesting thread.
14+
/// </summary>
15+
/// <remarks>This property is thread-safe.</remarks>
16+
public static object ThreadWide => _lockpool.Value;
17+
18+
19+
public static readonly object ProcessWide = new object();
20+
}
21+
}

0 commit comments

Comments
 (0)