After https://github.com/mono/mono/commit/
089c47f1c07bf250d76c36e04675569fc6f5b4ba#diff-e7e458b6256eaa730c145f14a666652aR1141
the code started to use nanoseconds instead of milliseconds. The problem was that this caused 'sleep_interruptable' to spin wait the last millisecond before the wait was over, https://bugzilla.xamarin.com/show_bug.cgi?id=44132.
Fix https://bugzilla.xamarin.com/show_bug.cgi?id=44132
*alerted = FALSE;
if (ms != INFINITE)
- end = mono_100ns_ticks () + (ms * 1000 * 10);
+ end = mono_msec_ticks() + ms;
mono_lazy_initialize (&sleep_init, sleep_initialize);
for (;;) {
if (ms != INFINITE) {
- now = mono_100ns_ticks ();
- if (now > end)
+ now = mono_msec_ticks();
+ if (now >= end)
break;
}
}
if (ms != INFINITE)
- mono_coop_cond_timedwait (&sleep_cond, &sleep_mutex, (end - now) / 10 / 1000);
+ mono_coop_cond_timedwait (&sleep_cond, &sleep_mutex, end - now);
else
mono_coop_cond_wait (&sleep_cond, &sleep_mutex);