@@ -10,6 +10,7 @@ use std::mem::transmute;
10
10
use std:: num:: NonZeroU32 ;
11
11
#[ cfg( unix) ]
12
12
use std:: os:: unix:: io:: RawFd ;
13
+ use std:: time:: Duration ;
13
14
use translate:: { from_glib, from_glib_full, FromGlib , ToGlib , ToGlibPtr } ;
14
15
#[ cfg( any( unix, feature = "dox" ) ) ]
15
16
use IOCondition ;
@@ -197,14 +198,14 @@ where
197
198
///
198
199
/// The default main loop almost always is the main loop of the main thread.
199
200
/// Thus the closure is called on the main thread.
200
- pub fn timeout_add < F > ( interval : u32 , func : F ) -> SourceId
201
+ pub fn timeout_add < F > ( interval : Duration , func : F ) -> SourceId
201
202
where
202
203
F : FnMut ( ) -> Continue + Send + ' static ,
203
204
{
204
205
unsafe {
205
206
from_glib ( glib_sys:: g_timeout_add_full (
206
207
glib_sys:: G_PRIORITY_DEFAULT ,
207
- interval,
208
+ interval. as_millis ( ) as _ ,
208
209
Some ( trampoline :: < F > ) ,
209
210
into_raw ( func) ,
210
211
Some ( destroy_closure :: < F > ) ,
@@ -228,15 +229,15 @@ where
228
229
///
229
230
/// This function panics if called from a different thread than the one that
230
231
/// owns the main context.
231
- pub fn timeout_add_local < F > ( interval : u32 , func : F ) -> SourceId
232
+ pub fn timeout_add_local < F > ( interval : Duration , func : F ) -> SourceId
232
233
where
233
234
F : FnMut ( ) -> Continue + ' static ,
234
235
{
235
236
unsafe {
236
237
assert ! ( MainContext :: default ( ) . is_owner( ) ) ;
237
238
from_glib ( glib_sys:: g_timeout_add_full (
238
239
glib_sys:: G_PRIORITY_DEFAULT ,
239
- interval,
240
+ interval. as_millis ( ) as _ ,
240
241
Some ( trampoline :: < F > ) ,
241
242
into_raw ( func) ,
242
243
Some ( destroy_closure :: < F > ) ,
@@ -536,7 +537,7 @@ where
536
537
/// be delayed by other events. Prefer `timeout_add_seconds` when millisecond
537
538
/// precision is not necessary.
538
539
pub fn timeout_source_new < F > (
539
- interval : u32 ,
540
+ interval : Duration ,
540
541
name : Option < & str > ,
541
542
priority : Priority ,
542
543
func : F ,
@@ -545,7 +546,7 @@ where
545
546
F : FnMut ( ) -> Continue + Send + ' static ,
546
547
{
547
548
unsafe {
548
- let source = glib_sys:: g_timeout_source_new ( interval) ;
549
+ let source = glib_sys:: g_timeout_source_new ( interval. as_millis ( ) as _ ) ;
549
550
glib_sys:: g_source_set_callback (
550
551
source,
551
552
Some ( trampoline :: < F > ) ,
0 commit comments