Parameters: |
|
---|
Prepare and Check watchers are usually (but not always) used in pairs: Prepare watchers get invoked before the process blocks and Check watchers afterwards.
You must not call Loop.start() or similar methods that enter the current event loop from either Prepare or Check watchers. Other loops than the current one are fine, however. The rationale behind this is that you do not need to check for recursion in those watchers, i.e. the sequence will always be: Prepare -> blocking -> Check, so if you have one watcher of each kind they will always be called in pairs bracketing the blocking call.
Their main purpose is to integrate other event mechanisms into libev and their use is somewhat advanced. They could be used, for example, to track variable changes, implement your own watchers, integrate net-snmp or a coroutine library and lots more. They are also occasionally useful if you cache some data and want to flush it before blocking.
It is recommended to give Check watchers highest (EV_MAXPRI) priority, to ensure that they are being run before any other watchers after the poll (this doesn’t matter for Prepare watchers).
Also, Check watchers (and Prepare watchers, too) should not activate/feed events into libev. While libev fully supports this, they might get executed before other Check watchers did their job.