예제 #1
0
 /// <summary> Set the function to call at the point at which all threads reach the
 /// rendezvous. This function is run exactly once, by the thread
 /// that trips the barrier. The function is not run if the barrier is
 /// broken.
 /// </summary>
 /// <param name="function">the function to run. If null, no function is run.
 /// </param>
 /// <returns> the previous function
 ///
 /// </returns>
 public virtual IRendezvousFunction SetRendezvousFunction(IRendezvousFunction function)
 {
     lock (this)
     {
         IRendezvousFunction old = rendezvousFunction_;
         rendezvousFunction_ = function;
         return(old);
     }
 }
예제 #2
0
        /// <summary> Create a Barrier for the indicated number of parties.
        /// and the given function to run at each barrier point.
        /// </summary>
        /// <exception cref="ArgumentException">if parties less than or equal to zero.
        ///
        /// </exception>

        public Rendezvous(int parties, IRendezvousFunction function)
        {
            if (parties <= 0)
            {
                throw new System.ArgumentException();
            }
            parties_            = parties;
            rendezvousFunction_ = function;
            entryGate_          = new WaiterPreferenceSemaphore(parties);
            slots_ = new System.Object[parties];
        }
예제 #3
0
 /// <summary> Set the function to call at the point at which all threads reach the
 /// rendezvous. This function is run exactly once, by the thread
 /// that trips the barrier. The function is not run if the barrier is
 /// broken. 
 /// </summary>
 /// <param name="function">the function to run. If null, no function is run.
 /// </param>
 /// <returns> the previous function
 /// 
 /// </returns>				
 public virtual IRendezvousFunction SetRendezvousFunction(IRendezvousFunction function)
 {
     lock (this)
     {
         IRendezvousFunction old = rendezvousFunction_;
         rendezvousFunction_ = function;
         return old;
     }
 }
예제 #4
0
 /// <summary> Create a Barrier for the indicated number of parties.
 /// and the given function to run at each barrier point.
 /// </summary>
 /// <exception cref="ArgumentException">if parties less than or equal to zero.
 /// 
 /// </exception>
 public Rendezvous(int parties, IRendezvousFunction function)
 {
     if (parties <= 0)
         throw new System.ArgumentException();
     parties_ = parties;
     rendezvousFunction_ = function;
     entryGate_ = new WaiterPreferenceSemaphore(parties);
     slots_ = new System.Object[parties];
 }