/** **************************************************************************************** * Restores the previous writer after setting a new one using #PushWriter. * It is important to keep the right order when pushing and popping writers, as there * lifetime is externally managed. * (In standard use-cases, only one, app-specific writer should be pushed anyhow). * To give a little assurance, this method #PopWriter takes the same parameter as * #PushWriter does, to verify if the one to be removed is really the topmost. * * @param checkWriter The previously pushed writer (for checking of call order). ******************************************************************************************/ public void PopWriter(ReportWriter checkWriter) { try { Lock.Acquire(); if (writers.Count == 0) { ALIB.ERROR("No Writer to remove"); return; } if (writers.Peek() != checkWriter) { ALIB.ERROR("Report Writer is not actual"); return; } writers.Peek().NotifyActivation(Phase.End); writers.Pop(); if (writers.Count > 0) { writers.Peek().NotifyActivation(Phase.Begin); } } finally { Lock.Release(); } }
/** **************************************************************************************** * Restores the previous values after an invocation to #PushHaltFlags. ******************************************************************************************/ public void PopHaltFlags() { #if DEBUG bool stackEmptyError; #endif try { Lock.Acquire(); haltAfterReport.Pop(); #if DEBUG stackEmptyError = haltAfterReport.Count == 0; #endif } finally { Lock.Release(); } #if DEBUG if (stackEmptyError) { PushHaltFlags(true, true); ALIB.ERROR("Stack empty, too many pop operations"); } #endif }