申明一个Glib::TimeVal timeout变量,然后

while (yourcond) {
    timeout.assign_current_time();
    timeout.add_seconds(2);     // 2 seconds
    ...timed_wait(*obj, timeout);
}