]> mj.ucw.cz Git - libucw.git/blob - ucw/doc/mainloop.txt
Merge branch 'dev-lib' of ssh://git.ucw.cz/projects/sherlock/GIT/sherlock into dev-lib
[libucw.git] / ucw / doc / mainloop.txt
1 Mainloop
2 ========
3
4 Not every program is strictly sequential. Sometimes, an event-driven
5 model is much easier to grasp. A fine example of such a program could
6 be a railway server. It has a separate connection to each station
7 and also to each train, so that it knows where each of them is (and
8 that neither a train nor a station have got missing). So it has to wait
9 for events coming from these connections and handle them appropriately.
10 It also processes other events that it has itself generated -- for
11 example various timers telling that a train is scheduled to depart
12 from some station.
13
14 The mainloop module takes care of the low-level part of event-driven
15 programs: it calls the OS to monitor file activity, to interrupt
16 the program at the right moment to serve a timer, and so on. The
17 programmer only defines hooks that should be called to handle
18 the events and calls mainloop functions to schedule them.
19
20 // TODO Example?
21
22 - <<conventions,Conventions>>
23 - <<time,Time and timers>>
24 - <<file,Activity on file descriptors>>
25 - <<hooks,Loop hooks>>
26 - <<process,Child processes>>
27 - <<control,Control of the mainloop>>
28
29 !!ucw/mainloop.h