Exemple #1
0
 public static bool Create(bool initiallyOwned,
                           out MutexHandle handle)
 {
     unsafe
     {
         fixed(MutexHandle *handlePtr = &handle)
         {
             return(CreateImpl(initiallyOwned, handlePtr));
         }
     }
 }
Exemple #2
0
        public static void Dispose(MutexHandle handle)
        {
            Tracing.Log(Tracing.Debug, "MutexHandle.Dispose(id={0:x8})",
                        handle.id);

            //
            // Releasing the handle will allow the mutex to be
            // garbage-collected.
            //
            Thread.CurrentProcess.ReleaseHandle(handle.id);
        }
Exemple #3
0
        public static bool IsOwnedByCurrentThread(MutexHandle handle)
        {
            Tracing.Log(Tracing.Debug, "MutexHandle.IsOwnedByCurrentThread(id={0:x8})",
                        handle.id);

            //
            // Convert the handle to a mutex; check the ownership of the mutex.
            //
            Mutex mutex = HandleTable.GetHandle(handle.id) as Mutex;

            return(mutex.IsOwnedByCurrentThread());
        }
Exemple #4
0
        public static void Release(MutexHandle handle)
        {
            Tracing.Log(Tracing.Debug, "MutexHandle.Release(id={0:x8})",
                        handle.id);

            //
            // Convert the handle to a mutex; release the mutex.
            //
            Mutex mutex = HandleTable.GetHandle(handle.id) as Mutex;

            mutex.ReleaseMutex();
        }
Exemple #5
0
        public static bool Create(bool initiallyOwned,
                                  out MutexHandle handle)
        {
            //
            // Create a new mutex, and a handle in the current process
            // to hold it.
            //
            //  Note: the mutex is created as a non-kernel object so that
            //  SIP threads owning mutex can be forcibly stopped
            //
            handle = new MutexHandle(Thread.CurrentProcess.AllocateHandle(
                                         new Mutex(initiallyOwned, false)));

            Tracing.Log(Tracing.Debug, "MutexHandle.Create(, out id={0:x8})",
                        handle.id);
            return(true);
        }
Exemple #6
0
 public static extern bool IsOwnedByCurrentThread(MutexHandle handle);
Exemple #7
0
 public static extern void Release(MutexHandle handle);
Exemple #8
0
 public static extern void Dispose(MutexHandle handle);