Skip to content

Commit

Permalink
Shorter sleep in thread_sleep test.
Browse files Browse the repository at this point in the history
  • Loading branch information
goyox86 committed Dec 11, 2024
1 parent e9d751b commit 35f90e0
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion crates/rb-sys-tests/src/stable_api_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,6 @@ parity_test!(
name: test_rb_thread_sleep,
func: thread_sleep,
data_factory: {
std::time::Duration::from_secs(1)
std::time::Duration::from_millis(100)
}
);
3 changes: 2 additions & 1 deletion crates/rb-sys/src/stable_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
use crate::VALUE;
use std::{
os::raw::{c_char, c_long},
ptr::NonNull, time::Duration,
ptr::NonNull,
time::Duration,
};

pub trait StableApiDefinition {
Expand Down
8 changes: 4 additions & 4 deletions crates/rb-sys/src/stable_api/compiled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,14 @@ impl StableApiDefinition for Definition {

#[inline]
fn thread_sleep(&self, duration: Duration) {
let seconds = duration.as_secs() as i64;
let microseconds = duration.subsec_micros() as i64;
let seconds = duration.as_secs() as _;
let microseconds = duration.subsec_micros() as _;

let time = crate::timeval {
tv_sec: seconds,
tv_usec: microseconds,
};

unsafe { impl_thread_sleep(time) }
}
}
}
6 changes: 3 additions & 3 deletions crates/rb-sys/src/stable_api/ruby_2_6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl StableApiDefinition for Definition {
if self.special_const_p(obj) {
true
} else {
let rbasic = obj as *const crate::Rbasic;
let rbasic = obj as *const crate::RBasic;
((*rbasic).flags & crate::ruby_fl_type::RUBY_FL_FREEZE as VALUE) != 0
}
}
Expand Down Expand Up @@ -266,8 +266,8 @@ impl StableApiDefinition for Definition {

#[inline]
fn thread_sleep(&self, duration: Duration) {
let seconds = duration.as_secs() as i64;
let microseconds = duration.subsec_micros() as i64;
let seconds = duration.as_secs() as _;
let microseconds = duration.subsec_micros() as _;

let time = crate::timeval {
tv_sec: seconds,
Expand Down
4 changes: 2 additions & 2 deletions crates/rb-sys/src/stable_api/ruby_2_7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ impl StableApiDefinition for Definition {

#[inline]
fn thread_sleep(&self, duration: Duration) {
let seconds = duration.as_secs() as i64;
let microseconds = duration.subsec_micros() as i64;
let seconds = duration.as_secs() as _;
let microseconds = duration.subsec_micros() as _;

let time = crate::timeval {
tv_sec: seconds,
Expand Down
4 changes: 2 additions & 2 deletions crates/rb-sys/src/stable_api/ruby_3_0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ impl StableApiDefinition for Definition {

#[inline]
fn thread_sleep(&self, duration: Duration) {
let seconds = duration.as_secs() as i64;
let microseconds = duration.subsec_micros() as i64;
let seconds = duration.as_secs() as _;
let microseconds = duration.subsec_micros() as _;

let time = crate::timeval {
tv_sec: seconds,
Expand Down
4 changes: 2 additions & 2 deletions crates/rb-sys/src/stable_api/ruby_3_1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ impl StableApiDefinition for Definition {

#[inline]
fn thread_sleep(&self, duration: Duration) {
let seconds = duration.as_secs() as i64;
let microseconds = duration.subsec_micros() as i64;
let seconds = duration.as_secs() as _;
let microseconds = duration.subsec_micros() as _;

let time = crate::timeval {
tv_sec: seconds,
Expand Down
4 changes: 2 additions & 2 deletions crates/rb-sys/src/stable_api/ruby_3_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ impl StableApiDefinition for Definition {

#[inline]
fn thread_sleep(&self, duration: Duration) {
let seconds = duration.as_secs() as i64;
let microseconds = duration.subsec_micros() as i64;
let seconds = duration.as_secs() as _;
let microseconds = duration.subsec_micros() as _;

let time = crate::timeval {
tv_sec: seconds,
Expand Down
6 changes: 3 additions & 3 deletions crates/rb-sys/src/stable_api/ruby_3_3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,14 @@ impl StableApiDefinition for Definition {

#[inline]
fn thread_sleep(&self, duration: Duration) {
let seconds = duration.as_secs() as i64;
let microseconds = duration.subsec_micros() as i64;
let seconds = duration.as_secs() as _;
let microseconds = duration.subsec_micros() as _;

let time = crate::timeval {
tv_sec: seconds,
tv_usec: microseconds,
};

unsafe { crate::rb_thread_wait_for(time) }
}
}
4 changes: 2 additions & 2 deletions crates/rb-sys/src/stable_api/ruby_3_4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ impl StableApiDefinition for Definition {

#[inline]
fn thread_sleep(&self, duration: Duration) {
let seconds = duration.as_secs() as i64;
let microseconds = duration.subsec_micros() as i64;
let seconds = duration.as_secs() as _;
let microseconds = duration.subsec_micros() as _;

let time = crate::timeval {
tv_sec: seconds,
Expand Down

0 comments on commit 35f90e0

Please sign in to comment.