From: <sv...@ww...> - 2005-12-23 19:49:15
|
Author: mkrose Date: 2005-12-23 11:48:55 -0800 (Fri, 23 Dec 2005) New Revision: 1801 Modified: trunk/CSP/csp/cspsim/Bus.h Log: Add convenience method for pushing data channels only when the value changes. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1801 Modified: trunk/CSP/csp/cspsim/Bus.h =================================================================== --- trunk/CSP/csp/cspsim/Bus.h 2005-12-23 05:53:48 UTC (rev 1800) +++ trunk/CSP/csp/cspsim/Bus.h 2005-12-23 19:48:55 UTC (rev 1801) @@ -380,6 +380,18 @@ push(); } + /** Set the channel value and signal the change to listeners if the value has + * changed. + * + * Should only be called for push channels (asserts false otherwise). + */ + void pushOnChange(const T& value) { + if (m_Value != value) { + m_Value = value; + push(); + } + } + /** Set a handler for a non-shared data channel that will be called when * a holder of a const reference to the channel requests that a new value * be set. The handler can honor this request by setting the channel |