##// END OF EJS Templates
Added class Trace<T> to manage channels for individual classes, if SomeClass...
Added class Trace<T> to manage channels for individual classes, if SomeClass uses Trace<SomeClass> it sould be marked with TraceSourceAttribute

File last commit:

r129:471f596b2603 v2
r212:a01d9df88d74 v2
Show More
Signal.cs
31 lines | 737 B | text/x-csharp | CSharpLexer
using System;
using System.Threading;
namespace Implab.Parallels {
/// <summary>
/// Implements a simple signalling logic using <see cref="Monitor.PulseAll(object)"/>.
/// </summary>
public class Signal {
readonly object m_lock = new object();
bool m_state;
public void Set() {
lock(m_lock) {
m_state = true;
Monitor.PulseAll(m_lock);
}
}
public void Wait() {
lock (m_lock)
if (!m_state)
Monitor.Wait(m_lock);
}
public bool Wait(int timeout) {
lock (m_lock)
return m_state || Monitor.Wait(m_lock, timeout);
}
}
}