/// <summary> /// Acquires a Synchronization Channel. A synch channel is used once by one /// object that wishes to be synchronized. Once all channels that have been /// acquired from a synchronizer have had their 'Synchronize' methods called, /// all channels' users are allowed to proceed. Note that the constructor need /// not be called from a DetachableEvent thread - but Synchronize(...) will /// need to be. /// </summary> /// <param name="sequencer">A sequence indicator that determines which synch /// channels' owners are instructed to proceed first.</param> /// <returns>A Synch Channel with the assigned priority.</returns> public ISynchChannel GetSynchChannel(IComparable sequencer) { ISynchChannel synchChannel = new SynchChannel(this, sequencer); m_synchChannels.Add(synchChannel); return(synchChannel); }
private void LogSynchronization(object sortKey, IDetachableEventController idec, SynchChannel sc) { if (m_waiters.ContainsValue(idec)) { throw new ApplicationException("Synchronize(...) called on a SynchChannel that is already waiting."); } if (!m_synchChannels.Contains(sc)) { throw new ApplicationException("SynchChannel applied to a synchronizer that did not own it - serious error."); } if ((m_waiters.Count + 1) == m_synchChannels.Count) { m_exec.RequestEvent(new ExecEventReceiver(LaunchAll), m_exec.Now, m_exec.CurrentPriorityLevel, null); } m_waiters.Add(sortKey, idec); idec.SetAbortHandler(new DetachableEventAbortHandler(idec_AbortionEvent)); idec.Suspend(); idec.ClearAbortHandler(); }