public static void cleanNotifier(IntPtr notifier_pointer, ref int status) { lock (s_notifierMutex) { Notifier notifier = Notifiers[notifier_pointer.ToInt32()]; if (notifier.prev != null) notifier.prev.next = notifier.next; if (notifier.next != null) notifier.next.prev = notifier.prev; if (notifiers == notifier) notifiers = notifier.next; Notifiers.Remove(notifier_pointer.ToInt32()); s_notifierCount--; } if (Interlocked.Decrement(ref notifierRefCount) == 0) { lock (s_notifierInterruptMutex) { if (s_alarm != null) { //Clean up alarm and manager s_alarm.Dispose(); s_alarm = null; //Reset closest trigger to max value for next time. closestTrigger = ulong.MaxValue; } } } }
public static IntPtr initializeNotifier(Action<ulong, IntPtr> process, IntPtr param, ref int status) { if (process == null) { status = HALErrorConstants.NULL_PARAMETER; return IntPtr.Zero; } if (Interlocked.Increment(ref notifierRefCount) == 1) { lock (s_notifierInterruptMutex) { //Create manager and alarm if not already created s_alarm = new NotifierAlarm(AlarmCallback); } } lock (s_notifierMutex) { Notifier notifier = new Notifier(); notifier.prev = null; notifier.next = notifiers; if (notifier.next != null) notifier.next.prev = notifier; notifier.param = param; notifier.process = process; notifier.index = s_notifierCount; notifiers = notifier; Notifiers.Add(s_notifierCount, notifier); s_notifierCount++; return (IntPtr)s_notifierCount - 1; } }
public static void cleanNotifier(IntPtr notifier_pointer, ref int status) { lock (s_notifierMutex) { Notifier notifier = Notifiers[notifier_pointer.ToInt32()]; if (notifier.prev != null) notifier.prev.next = notifier.next; if (notifier.next != null) notifier.next.prev = notifier.prev; if (notifiers == notifier) notifiers = notifier.next; Notifiers.Remove(notifier_pointer.ToInt32()); } if (Interlocked.Decrement(ref notifierRefCount) == 0) { lock (s_notifierInterruptMutex) { if (s_alarm != null) { //Clean up alarm and manager s_alarm.Dispose(); s_alarm = null; } } } }