next up previous contents
Next: About this document ... Up: listener Previous: Example 5: RadioStation   Contents

Example 6: Priority

Show how to use the priority. In this example, 3 Subscribers are created ( $ s[i], 0 \leqslant i \leqslant 2$ ), with different priorities. The higuest priority is 0 (default value).
  using namespace listener ;

  class Event0: public Event {
  } ;

  class S: public Subscriber {
  public:
    void receives(Event0*) {}
  } ;

  int main() {
    Publisher p ;
    S s[3] ;
  
    // Connections using priority (last argument)
    igs_connect(&p, &s[0], igs_functor(&s[0], S::receives), 110) ;
    igs_connect(&p, &s[1], igs_functor(&s[1], S::receives), 2761) ;
    igs_connect(&p, &s[2], igs_functor(&s[2], S::receives), 0) ;

    p.igs_emit(Event0) ;
  }
Order of call:
  s[2] // with priority 0
  s[0] // with priority 110
  s[1] // with priority 2761



Frantz Maerten 2006-01-30