You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Locks.cs 605 B

6 years ago
123456789101112131415161718192021
  1. using System.Threading;
  2. namespace Tensorflow.Util
  3. {
  4. /// <summary>
  5. /// Provides a set of locks on different shared levels.
  6. /// </summary>
  7. public static class Locks
  8. {
  9. private static readonly ThreadLocal<object> _lockpool = new ThreadLocal<object>(() => new object());
  10. /// <summary>
  11. /// A seperate lock for every requesting thread.
  12. /// </summary>
  13. /// <remarks>This property is thread-safe.</remarks>
  14. public static object ThreadWide => _lockpool.Value;
  15. public static readonly object ProcessWide = new object();
  16. }
  17. }