@@ -1860,31 +1860,35 @@ _dispatch_timers_get_delay(uint64_t nows[], struct dispatch_timer_s timer[],
1860
1860
1861
1861
1862
1862
#ifdef __linux__
1863
- // in linux we map the _dispatch_kevent_qos_s to struct kevent instead of struct kevent64.
1864
- // we loose the kevent.ext[] members and the time out is based on relavite msec based time
1865
- // vs. absolute nsec based time. For now we make the adjustments right here until the solution
1866
- // to either extend libkqueue with a proper kevent64 API or removing kevent all together
1867
- // and move to a lower API (e.g. epoll or kernel_module. Also leeway is ignored.
1863
+ // in linux we map the _dispatch_kevent_qos_s to struct kevent instead
1864
+ // of struct kevent64. We loose the kevent.ext[] members and the time
1865
+ // out is based on relavite msec based time vs. absolute nsec based time.
1866
+ // For now we make the adjustments right here until the solution
1867
+ // to either extend libkqueue with a proper kevent64 API or removing kevent
1868
+ // all together and move to a lower API (e.g. epoll or kernel_module.
1869
+ // Also leeway is ignored.
1868
1870
1869
1871
static void
1870
- kevent_set_delay (_dispatch_kevent_qos_s * ke , uint64_t delay ,uint64_t leeway , uint64_t nows [])
1872
+ _dispatch_kevent_timer_set_delay (_dispatch_kevent_qos_s * ke , uint64_t delay ,
1873
+ uint64_t leeway , uint64_t nows [])
1871
1874
{
1872
- _dispatch_source_timer_now (nows , DISPATCH_TIMER_KIND_WALL ); // called to return nows[]
1873
-
1875
+ // call to return nows[]
1876
+ _dispatch_source_timer_now (nows , DISPATCH_TIMER_KIND_WALL );
1877
+ // adjust nsec based delay to msec based and ignore leeway
1874
1878
delay /= 1000000L ;
1875
- if ((int64_t )(delay ) <= 0 )
1876
- delay = 1 ; /* if he value is negative or 0 then the dispatch will stop */
1879
+ if ((int64_t )(delay ) <= 0 ) {
1880
+ delay = 1 ; // if value <= 0 the dispatch will stop
1881
+ }
1877
1882
ke -> data = (int64_t )delay ;
1878
1883
}
1879
1884
1880
1885
#else
1881
1886
1882
1887
static void
1883
- kevent_set_delay (_dispatch_kevent_qos_s * ke , uint64_t delay ,uint64_t leeway , uint64_t nows [])
1888
+ _dispatch_kevent_timer_set_delay (_dispatch_kevent_qos_s * ke , uint64_t delay ,
1889
+ uint64_t leeway , uint64_t nows [])
1884
1890
{
1885
-
1886
1891
delay += _dispatch_source_timer_now (nows , DISPATCH_TIMER_KIND_WALL );
1887
-
1888
1892
if (slowpath (_dispatch_timers_force_max_leeway )) {
1889
1893
ke -> data = (int64_t )(delay + leeway );
1890
1894
ke -> ext [1 ] = 0 ;
@@ -1918,12 +1922,10 @@ _dispatch_timers_program2(uint64_t nows[], _dispatch_kevent_qos_s *ke,
1918
1922
_dispatch_trace_next_timer_set (
1919
1923
TAILQ_FIRST (& _dispatch_kevent_timer [tidx ].dk_sources ), qos );
1920
1924
_dispatch_trace_next_timer_program (delay , qos );
1921
-
1922
- kevent_set_delay (ke ,delay ,leeway ,nows );
1925
+ _dispatch_kevent_timer_set_delay (ke , delay , leeway , nows );
1926
+ ke -> flags |= EV_ADD |EV_ENABLE ;
1927
+ ke -> flags &= ~EV_DELETE ;
1923
1928
}
1924
-
1925
- ke -> flags |= EV_ADD |EV_ENABLE ;
1926
- ke -> flags &= ~EV_DELETE ;
1927
1929
_dispatch_kq_update (ke );
1928
1930
return poll ;
1929
1931
}
0 commit comments