Skip to content

Commit

Permalink
[eclipse-iceoryx#264] Fix review findings
Browse files Browse the repository at this point in the history
  • Loading branch information
elfenpiff committed Sep 11, 2024
1 parent 7113938 commit d8a963a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 37 deletions.
7 changes: 4 additions & 3 deletions iceoryx2-ffi/cxx/src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,11 @@ void Service::set_dynamic_config_storage_suffix(const iox::FileName& value) && {

auto Service::creation_timeout() && -> iox::units::Duration {
auto* ref_handle = iox2_cast_config_ref_h(*m_config);
auto secs = iox2_config_global_service_creation_timeout_sec(ref_handle);
auto nsec = iox2_config_global_service_creation_timeout_nsec_frac(ref_handle);
uint64_t secs = 0;
uint32_t nsecs = 0;
iox2_config_global_service_creation_timeout(ref_handle, &secs, &nsecs);

return iox::units::Duration::fromSeconds(secs) + iox::units::Duration::fromNanoseconds(nsec);
return iox::units::Duration::fromSeconds(secs) + iox::units::Duration::fromNanoseconds(nsecs);
}

void Service::set_creation_timeout(const iox::units::Duration& value) && {
Expand Down
47 changes: 13 additions & 34 deletions iceoryx2-ffi/ffi/src/api/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ pub unsafe extern "C" fn iox2_config_from_file(
config_file: *const c_char,
) -> c_int {
debug_assert!(!handle_ptr.is_null());
debug_assert!(!config_file.is_null());

let file = match FilePath::from_c_str(config_file) {
Ok(file) => file,
Expand Down Expand Up @@ -878,50 +879,28 @@ pub unsafe extern "C" fn iox2_config_global_service_set_dynamic_config_storage_s
}
}

/// Returns the second part of the time of how long another process will wait until the service
/// Returns the duration how long another process will wait until the service
/// creation is finalized
///
/// # Safety
///
/// * `handle` - A valid non-owning [`iox2_config_ref_h`] obtained by [`iox2_cast_config_ref_h`].
/// * `secs` - A valid pointer pointing to a [`u64`].
/// * `nsecs` - A valid pointer pointing to a [`u32`]
#[no_mangle]
pub unsafe extern "C" fn iox2_config_global_service_creation_timeout_sec(
pub unsafe extern "C" fn iox2_config_global_service_creation_timeout(
handle: iox2_config_ref_h,
) -> u64 {
debug_assert!(!handle.is_null());

let config = &*handle.as_type();
config
.value
.as_ref()
.value
.global
.service
.creation_timeout
.as_secs()
}

/// Returns the nano second part of the time of how long another process will wait until the service
/// creation is finalized
///
/// # Safety
///
/// * `handle` - A valid non-owning [`iox2_config_ref_h`] obtained by [`iox2_cast_config_ref_h`].
#[no_mangle]
pub unsafe extern "C" fn iox2_config_global_service_creation_timeout_nsec_frac(
handle: iox2_config_ref_h,
) -> u32 {
secs: *mut u64,
nsecs: *mut u32,
) {
debug_assert!(!handle.is_null());
debug_assert!(!secs.is_null());
debug_assert!(!nsecs.is_null());

let config = &*handle.as_type();
config
.value
.as_ref()
.value
.global
.service
.creation_timeout
.subsec_nanos()
let timeout = config.value.as_ref().value.global.service.creation_timeout;
*secs = timeout.as_secs();
*nsecs = timeout.subsec_nanos();
}

/// Sets the creation timeout
Expand Down

0 comments on commit d8a963a

Please sign in to comment.