Fix handling of a mode 1 functor that feeds into a

mode 2 functor. Feed the result only if the event
 is triggered, and do pass to the output even if no
 threads are waiting.
This commit is contained in:
steve 2001-05-03 04:54:33 +00:00
parent 8f88525819
commit 12229e4826
1 changed files with 33 additions and 13 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: functor.cc,v 1.14 2001/04/26 15:52:22 steve Exp $" #ident "$Id: functor.cc,v 1.15 2001/05/03 04:54:33 steve Exp $"
#endif #endif
# include "functor.h" # include "functor.h"
@ -171,29 +171,43 @@ const unsigned char vvp_edge_anyedge[16] = {
1, 1, 1, 0 // z -> ... 1, 1, 1, 0 // z -> ...
}; };
/*
* A mode1 functor is a probe of some sort that is looking for an edge
* of some specified type on any of its inputs. If it finds the right
* kind of edge, then it awakens all the threads that are waiting on
* this functor *and* it schedules an assign for any output it might
* have. The latter is to support wider event/or then a single functor
* can support.
*/
static void functor_set_mode1(functor_t fp) static void functor_set_mode1(functor_t fp)
{ {
vvp_event_t ep = fp->event; vvp_event_t ep = fp->event;
for (unsigned idx = 0 ; ep->threads && (idx < 4) ; idx += 1) { /* Only go through the effort if there is someone interested
unsigned oval = (ep->ival >> 2*idx) & 3; in the results... */
unsigned nval = (fp->ival >> 2*idx) & 3;
unsigned val = (oval << 2) | nval; if (ep->threads || fp->out) {
unsigned char edge_p = ep->vvp_edge_tab[val];
if (edge_p) { for (unsigned idx = 0 ; idx < 4 ; idx += 1) {
vthread_t tmp = ep->threads; unsigned oval = (ep->ival >> 2*idx) & 3;
ep->threads = 0; unsigned nval = (fp->ival >> 2*idx) & 3;
vthread_schedule_list(tmp);
unsigned val = (oval << 2) | nval;
unsigned char edge_p = ep->vvp_edge_tab[val];
if (edge_p) {
vthread_t tmp = ep->threads;
ep->threads = 0;
vthread_schedule_list(tmp);
if (fp->out)
schedule_assign(fp->out, 0, 0);
}
} }
} }
/* the new value is the new old value. */ /* the new value is the new old value. */
ep->ival = fp->ival; ep->ival = fp->ival;
if (fp->out)
schedule_assign(fp->out, 0, 0);
} }
/* /*
@ -316,6 +330,12 @@ const unsigned char ft_var[16] = {
/* /*
* $Log: functor.cc,v $ * $Log: functor.cc,v $
* Revision 1.15 2001/05/03 04:54:33 steve
* Fix handling of a mode 1 functor that feeds into a
* mode 2 functor. Feed the result only if the event
* is triggered, and do pass to the output even if no
* threads are waiting.
*
* Revision 1.14 2001/04/26 15:52:22 steve * Revision 1.14 2001/04/26 15:52:22 steve
* Add the mode-42 functor concept to UDPs. * Add the mode-42 functor concept to UDPs.
* *