Idle Functions

Om du vill ange en metod som anropas när inget annat händer använder du följande:

sigc::connection  Glib::SignalIdle::connect(const sigc::slot<bool()>& slot,
                                    int priority = Glib::PRIORITY_DEFAULT_IDLE);

This causes gtkmm to call the specified method whenever nothing else is happening. You can add a priority (lower numbers are higher priorities). There are two ways to remove the signal handler: calling disconnect() on the sigc::connection object, or returning false in the signal handler, which should be declared as follows:

bool idleFunc();

Eftersom detta är väldigt likt metoderna ovan bör denna förklaring räcka för att förstå vad som pågår. Här kommer dock ett litet exempel:

Källkod

This example points out the difference of idle and timeout methods a little. If you need methods that are called periodically, and speed is not very important, then you want timeout methods. If you want methods that are called as often as possible (like calculating a fractal in background), then use idle methods.

Try executing the example and increasing the system load. The upper progress bar will increase steadily; the lower one will slow down.