예제 #1
0
 public static bool Create(bool initiallyOwned,
                           out MutexHandle handle)
 {
     unsafe
     {
         fixed(MutexHandle *handlePtr = &handle)
         {
             return(CreateImpl(initiallyOwned, handlePtr));
         }
     }
 }
예제 #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);
        }
예제 #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());
        }
예제 #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();
        }
예제 #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);
        }
예제 #6
0
 public static extern bool IsOwnedByCurrentThread(MutexHandle handle);
예제 #7
0
 public static extern void Release(MutexHandle handle);
예제 #8
0
 public static extern void Dispose(MutexHandle handle);