const int TIMEOUT = 20;
const int SERVICE = 10;
long ncount = 0;
Facility Box("Box");
Histogram Table("Table", 0, 1, SERVICE+TIMEOUT+1);
class Timeout : public Event {
Process *ptr;
public:
Timeout(
double t, Process *p): ptr(p) {
}
void Behavior() {
delete ptr;
ncount++;
}
};
class Customer : public Process {
double ArrivalTime;
void Behavior() {
Event *timeout = new Timeout(TIMEOUT,this);
Seize(Box);
delete timeout;
Wait(SERVICE);
Release(Box);
}
};
class Generator : public Event {
void Behavior() {
}
};
Print(
"model2-timeout -- SIMLIB/C++ example\n");
Print(
"Number of impatient customers: %d \n", ncount);
Box.Output();
Table.Output();
}