Ejemplo n.º 1
0
        /// <summary>
        /// Acquires the reader
        ///     If there is no convention the readers will just continue reading for as
        ///     long as they need to
        /// </summary>
        public void AcquireReader()
        {
            // ---------------------- #1 TS -------------------------------------------------------
            // Should be signed if there there is something waiting and should be released when the last
            //  thread has finished with the LS
            readerTS.Acquire();
            readerTS.Release();

            lock (lockObject) {
                ++readersWaiting;                       // Used to figure out when the last reader has finished with the LS
            }
            // -------------------------------------------------------------------------------------


            LS.Acquire();                                               // << ADDS READER TO LS

            lock (lockObject) {
                --readersWaiting;

                // If readers waiting then pulse
                if (readersWaiting != 0)
                {
                    Monitor.Pulse(lockObject);
                }
            }
        }
Ejemplo n.º 2
0
 private void PutTask()
 {
     lock (this.SyncObject1)
     {
         this.Value = "put";
         Monitor.Pulse(this.SyncObject1);
     }
 }
Ejemplo n.º 3
0
 public void RequestExitAndWait()
 {
     // don't call this from GLThread thread or it is a guaranteed
     // deadlock!
     //synchronized (this) {
     lock (locker)
     {
         this.mDone = true;
         //this.notify();
         Monitor.Pulse(locker);
     }
     try
     {
         //this.join();
         //Thread.CurrentThread().Join();
         System.Threading.Monitor.Enter(locker);
     }
     catch (InterruptedException ex)
     {
         Java.Lang.Thread.CurrentThread().Interrupt();
     }
     // TODO: Added this call ... check it
     finally { System.Threading.Monitor.Exit(locker); }
 }
 public static void Pulse(object obj)
 {
     SMonitor.Pulse(obj);
 }