// $Id$ // The famous Dining Philosopher example in CCM tutorial slides module Example { exception InUse {}; interface Fork /** * Provided facet interface definition. * It should be defined by the IDL file. */ { void get () raises (InUse); void release (); }; component ForkManager { provides Fork the_fork; }; home ForkHome manages ForkManager { }; enum PhilosopherState { EATING, THINKING, HUNGRY, STARVING, DEAD }; eventtype StatusInfo { public string name; public PhilosopherState state; public unsigned long ticks_since_last_meal; public boolean has_left_fork; public boolean has_right_fork; }; component Philosopher { attribute string name; // The left fork receptacle. uses Fork left; // The right fork receptacle. uses Fork right; // The status info event source. publishes StatusInfo info; }; home PhilosopherHome manages Philosopher { factory new (in string name); }; component Observer { // The status info sink port. consumes StatusInfo info; }; home ObserverHome manages Observer { }; };