public EventDispatcher( IGrandOutputDispatcherStrategy strategy, Action<TimeSpan> onIdle = null ) { Debug.Assert( strategy != null ); _queue = new ConcurrentQueue<EventItem>(); _dispatchLock = new object(); _strat = strategy; _onIdle = onIdle; _overloadLock = new object(); _thread = new Thread( Run ); _thread.IsBackground = true; _strat.Initialize( () => _nonBlockingCount, _thread, out _idleManager ); _thread.Start(); }
public EventDispatcher(IGrandOutputDispatcherStrategy strategy, Action <TimeSpan> onIdle = null) { Debug.Assert(strategy != null); _queue = new ConcurrentQueue <EventItem>(); _dispatchLock = new object(); _strat = strategy; _onIdle = onIdle; _overloadLock = new object(); _thread = new Thread(Run); _thread.IsBackground = true; _strat.Initialize(() => _nonBlockingCount, _thread, out _idleManager); _thread.Start(); }
public void Dispose() { Interlocked.MemoryBarrier(); var strat = _strat; if (strat != null) { _strat = null; Interlocked.MemoryBarrier(); DoAdd(new GrandOutputEventInfo(), null); GC.SuppressFinalize(this); _thread.Join(); } }
/// <summary> /// Initializes a new <see cref="GrandOutput"/>. /// </summary> /// <param name="dispatcherStrategy">Strategy to use to handle the throughput.</param> public GrandOutput( IGrandOutputDispatcherStrategy dispatcherStrategy = null ) { _clients = new List<WeakReference<GrandOutputClient>>(); _dispatcher = new EventDispatcher( dispatcherStrategy ?? new EventDispatcherBasicStrategy(), null ); CommonSink = new GrandOutputCompositeSink(); var factory = new ChannelFactory( this, _dispatcher ); _channelHost = new ChannelHost( factory, OnConfigurationReady ); _channelHost.ConfigurationClosing += OnConfigurationClosing; _bufferingChannel = new BufferingChannel( _dispatcher, factory.CommonSinkOnlyReceiver ); _nextDeadClientGarbage = DateTime.UtcNow.AddMinutes( 5 ); // TODO: Adapt this termination handling to dotnet. var h = new EventHandler( OnDomainTermination ); AppDomain.CurrentDomain.DomainUnload += h; AppDomain.CurrentDomain.ProcessExit += h; }
/// <summary> /// Initializes a new <see cref="GrandOutput"/>. /// </summary> /// <param name="dispatcherStrategy">Strategy to use to handle the throughput.</param> public GrandOutput(IGrandOutputDispatcherStrategy dispatcherStrategy = null) { _clients = new List <WeakReference <GrandOutputClient> >(); _dispatcher = new EventDispatcher(dispatcherStrategy ?? new EventDispatcherBasicStrategy(), null); CommonSink = new GrandOutputCompositeSink(); var factory = new ChannelFactory(this, _dispatcher); _channelHost = new ChannelHost(factory, OnConfigurationReady); _channelHost.ConfigurationClosing += OnConfigurationClosing; _bufferingChannel = new BufferingChannel(_dispatcher, factory.CommonSinkOnlyReceiver); _nextDeadClientGarbage = DateTime.UtcNow.AddMinutes(5); // TODO: Adapt this termination handling to dotnet. var h = new EventHandler(OnDomainTermination); AppDomain.CurrentDomain.DomainUnload += h; AppDomain.CurrentDomain.ProcessExit += h; }
public void Dispose() { Interlocked.MemoryBarrier(); var strat = _strat; if( strat != null ) { _strat = null; Interlocked.MemoryBarrier(); DoAdd( new GrandOutputEventInfo(), null ); GC.SuppressFinalize( this ); _thread.Join(); } }