Skip to content

Rust::com General Optimization and cleanup of RUST-API#276

Open
bharatGoswami8 wants to merge 6 commits intoeclipse-score:mainfrom
bharatGoswami8:com_api_optimization
Open

Rust::com General Optimization and cleanup of RUST-API#276
bharatGoswami8 wants to merge 6 commits intoeclipse-score:mainfrom
bharatGoswami8:com_api_optimization

Conversation

@bharatGoswami8
Copy link
Copy Markdown
Contributor

@bharatGoswami8 bharatGoswami8 commented Apr 8, 2026

  • cleanup for internal type naming of rust apis
  • Updated init async flag
  • added NonNull type for internal types of consumer and producer

@bharatGoswami8 bharatGoswami8 self-assigned this Apr 8, 2026
@bharatGoswami8 bharatGoswami8 changed the title Rust::com Rust Api optimization Rust::com General Optimization and cleanup of RUST-API Apr 8, 2026
@bharatGoswami8 bharatGoswami8 force-pushed the com_api_optimization branch 3 times, most recently from a8502a3 to 9219844 Compare April 10, 2026 11:14
@bharatGoswami8 bharatGoswami8 marked this pull request as ready for review April 10, 2026 11:15
@bharatGoswami8 bharatGoswami8 force-pushed the com_api_optimization branch 3 times, most recently from 7bd3067 to 6fb410c Compare April 13, 2026 04:21
Copy link
Copy Markdown

@rpreddyhv rpreddyhv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks okay to me.

.store(true, std::sync::atomic::Ordering::Relaxed);
}
// We are using std::sync::Once to ensure that the callback is set only once.
self.async_init_status.call_once(|| {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::sync::Once::call_once is a blocking, thread-parking primitive. Calling it inside an async block violates the fundamental async contract: futures must never block the executor thread.

suggestion: OnceLock (lock-free, non-blocking) or keep previous AtomicBool

Copy link
Copy Markdown
Contributor Author

@bharatGoswami8 bharatGoswami8 Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Async receive enforces single-threaded access via ProxyEventManager's in_progress acquire/release lock, concurrent calls panic immediately. call_once executes only once on first receive() call, blocking for microseconds (FFI callback setup only) because init should be done before returning future.
And also sync::once give clear indication to developer this is one time call.

@@ -259,23 +258,18 @@ impl NativeProxyEventBase {
pub fn new(proxy: *mut ProxyBase, interface_id: &str, identifier: &str) -> Result<Self> {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NonNull instead of *mut ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes why not, we can take as &NonNull

ProducerFailedReason::SkeletonCreationFailed,
));
}
let skeleton_event_ptr = std::ptr::NonNull::new(raw_event_ptr).ok_or(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line 310 used ok_or_else, here ok_or, seems inconsistent. please check other places as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it was only in this line updated.

));
}
let skeleton_event_ptr = std::ptr::NonNull::new(raw_event_ptr).ok_or(
Error::ProducerError(ProducerFailedReason::SkeletonCreationFailed),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SkeletonCreationFailed? is this correct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

/// As it has Send and Sync unsafe impls, it must not expose any mutable access to the skeleton handle
pub struct NativeSkeletonHandle {
pub handle: *mut SkeletonBase,
pub handle: NonNull<SkeletonBase>,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pub? comment say it must not expose any mutable access to the skeleton handle

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for pointing out this. Looks like in producer side few places still pub keyword was there for field.

* Changed init flag from automic to std::once
* Changed NativeSkeletonHandle to NonNull
* Updated Naming for Lola and Mock runtime internal type
* Consumer proxy and event type field updated to NonNull
* Updated receive algo document
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants