From 9195f457b8ce3dc040826f3b8541bda978fd2cce Mon Sep 17 00:00:00 2001 From: Piotr Korkus Date: Mon, 9 Feb 2026 12:24:02 +0100 Subject: [PATCH 1/3] update rust headers required by bumped tooling --- MODULE.bazel | 2 +- src/kyron-foundation/src/base/fast_rand.rs | 6 +++--- src/kyron-foundation/src/base/mod.rs | 6 +++--- src/kyron-foundation/src/cell/mod.rs | 6 +++--- src/kyron-foundation/src/containers/growable_vec.rs | 6 +++--- .../src/containers/intrusive_linked_list.rs | 6 +++--- src/kyron-foundation/src/containers/mod.rs | 6 +++--- src/kyron-foundation/src/containers/mpmc_queue.rs | 6 +++--- src/kyron-foundation/src/containers/queue.rs | 6 +++--- .../src/containers/reusable_objects.rs | 6 +++--- .../src/containers/reusable_vec_pool.rs | 6 +++--- src/kyron-foundation/src/containers/spmc_queue.rs | 6 +++--- src/kyron-foundation/src/containers/trigger_queue.rs | 6 +++--- .../src/containers/vector_extension.rs | 6 +++--- src/kyron-foundation/src/lib.rs | 6 +++--- src/kyron-foundation/src/macros/mod.rs | 6 +++--- src/kyron-foundation/src/prelude.rs | 6 +++--- src/kyron-foundation/src/sync/foundation_atomic.rs | 6 +++--- src/kyron-foundation/src/sync/mod.rs | 6 +++--- src/kyron-foundation/src/threading/mod.rs | 6 +++--- .../src/threading/thread_wait_barrier.rs | 6 +++--- src/kyron-foundation/src/types.rs | 6 +++--- src/kyron-macros/src/lib.rs | 6 +++--- src/kyron-testing-macros/src/lib.rs | 6 +++--- src/kyron-testing/src/lib.rs | 6 +++--- src/kyron-testing/src/mock_fn.rs | 6 +++--- src/kyron-testing/src/poller.rs | 6 +++--- src/kyron-testing/src/prelude.rs | 6 +++--- src/kyron-testing/src/waker.rs | 6 +++--- src/kyron/examples/main_macro.rs | 6 +++--- src/kyron/examples/mpmc.rs | 6 +++--- src/kyron/examples/playground.rs | 6 +++--- src/kyron/examples/safety_task.rs | 6 +++--- src/kyron/examples/select.rs | 6 +++--- src/kyron/src/channels/mod.rs | 6 +++--- src/kyron/src/channels/spmc_broadcast.rs | 6 +++--- src/kyron/src/channels/spsc.rs | 6 +++--- src/kyron/src/core/mod.rs | 6 +++--- src/kyron/src/core/types.rs | 6 +++--- src/kyron/src/futures/mod.rs | 6 +++--- src/kyron/src/futures/reusable_box_future.rs | 6 +++--- src/kyron/src/futures/sleep.rs | 6 +++--- src/kyron/src/futures/yield_now.rs | 6 +++--- src/kyron/src/io/async_registration.rs | 6 +++--- src/kyron/src/io/bridgedfd.rs | 6 +++--- src/kyron/src/io/driver.rs | 6 +++--- src/kyron/src/io/mod.rs | 6 +++--- src/kyron/src/io/read_buf.rs | 6 +++--- src/kyron/src/io/traits.rs | 6 +++--- src/kyron/src/io/utils/mod.rs | 6 +++--- src/kyron/src/io/utils/read_future.rs | 6 +++--- src/kyron/src/io/utils/write_future.rs | 6 +++--- src/kyron/src/ipc/iceoryx2/event.rs | 6 +++--- src/kyron/src/ipc/iceoryx2/mod.rs | 6 +++--- src/kyron/src/ipc/mod.rs | 6 +++--- src/kyron/src/lib.rs | 6 +++--- src/kyron/src/macros/mod.rs | 6 +++--- src/kyron/src/macros/select.rs | 6 +++--- src/kyron/src/mio/mod.rs | 6 +++--- src/kyron/src/mio/net/mod.rs | 6 +++--- src/kyron/src/mio/net/tcp_listener.rs | 6 +++--- src/kyron/src/mio/net/tcp_stream.rs | 6 +++--- src/kyron/src/mio/net/udp.rs | 6 +++--- src/kyron/src/mio/poll.rs | 6 +++--- src/kyron/src/mio/rawfd.rs | 6 +++--- src/kyron/src/mio/registry.rs | 6 +++--- src/kyron/src/mio/selector/mod.rs | 6 +++--- src/kyron/src/mio/selector/unix/poll.rs | 6 +++--- src/kyron/src/mio/types.rs | 6 +++--- src/kyron/src/net/mod.rs | 6 +++--- src/kyron/src/net/tcp_listener.rs | 6 +++--- src/kyron/src/net/tcp_stream.rs | 6 +++--- src/kyron/src/net/udp_socket.rs | 6 +++--- src/kyron/src/net/utils.rs | 6 +++--- src/kyron/src/prelude.rs | 6 +++--- src/kyron/src/runtime/mod.rs | 6 +++--- src/kyron/src/runtime/runtime_impl.rs | 6 +++--- src/kyron/src/safety.rs | 6 +++--- src/kyron/src/scheduler/context.rs | 6 +++--- src/kyron/src/scheduler/driver.rs | 6 +++--- src/kyron/src/scheduler/execution_engine.rs | 6 +++--- src/kyron/src/scheduler/join_handle.rs | 6 +++--- src/kyron/src/scheduler/mod.rs | 6 +++--- src/kyron/src/scheduler/safety_waker.rs | 6 +++--- src/kyron/src/scheduler/scheduler_mt.rs | 6 +++--- src/kyron/src/scheduler/task/async_task.rs | 6 +++--- src/kyron/src/scheduler/task/mod.rs | 6 +++--- src/kyron/src/scheduler/task/task_context.rs | 6 +++--- src/kyron/src/scheduler/task/task_state.rs | 6 +++--- src/kyron/src/scheduler/waker.rs | 6 +++--- src/kyron/src/scheduler/workers/dedicated_worker.rs | 6 +++--- src/kyron/src/scheduler/workers/mod.rs | 6 +++--- src/kyron/src/scheduler/workers/safety_worker.rs | 6 +++--- src/kyron/src/scheduler/workers/worker.rs | 6 +++--- src/kyron/src/scheduler/workers/worker_types.rs | 6 +++--- src/kyron/src/testing/mock.rs | 6 +++--- src/kyron/src/testing/mod.rs | 6 +++--- src/kyron/src/time/clock.rs | 6 +++--- src/kyron/src/time/mod.rs | 6 +++--- src/kyron/src/time/wheel.rs | 6 +++--- src/logging_tracing/src/lib.rs | 6 +++--- src/logging_tracing/src/log.rs | 6 +++--- src/logging_tracing/src/prelude.rs | 6 +++--- src/logging_tracing/src/tracing.rs | 6 +++--- src/xtask/src/main.rs | 12 ++++++------ tests/test_cases/BUILD | 4 ++-- .../rust/src/internals/execution_barrier.rs | 12 ++++++++++++ tests/test_scenarios/rust/src/internals/mod.rs | 12 ++++++++++++ .../test_scenarios/rust/src/internals/net_helper.rs | 12 ++++++++++++ .../rust/src/internals/runtime_helper.rs | 12 ++++++++++++ .../rust/src/internals/thread_params.rs | 12 ++++++++++++ tests/test_scenarios/rust/src/main.rs | 12 ++++++++++++ tests/test_scenarios/rust/src/scenarios/basic/mod.rs | 12 ++++++++++++ .../src/scenarios/basic/only_shutdown_sequence.rs | 12 ++++++++++++ tests/test_scenarios/rust/src/scenarios/mod.rs | 12 ++++++++++++ .../rust/src/scenarios/runtime/channel/mod.rs | 12 ++++++++++++ .../src/scenarios/runtime/channel/spmc_broadcast.rs | 12 ++++++++++++ .../rust/src/scenarios/runtime/channel/spsc.rs | 12 ++++++++++++ .../src/scenarios/runtime/execution_engine/mod.rs | 12 ++++++++++++ .../single_rt_multiple_exec_engine.rs | 12 ++++++++++++ .../test_scenarios/rust/src/scenarios/runtime/mod.rs | 12 ++++++++++++ .../rust/src/scenarios/runtime/net/mod.rs | 12 ++++++++++++ .../rust/src/scenarios/runtime/net/tcp/mod.rs | 12 ++++++++++++ .../rust/src/scenarios/runtime/net/tcp/server.rs | 12 ++++++++++++ .../src/scenarios/runtime/net/tcp/tcp_listener.rs | 12 ++++++++++++ .../rust/src/scenarios/runtime/net/tcp/tcp_stream.rs | 12 ++++++++++++ .../rust/src/scenarios/runtime/net/udp/mod.rs | 12 ++++++++++++ .../rust/src/scenarios/runtime/net/udp/udp_client.rs | 12 ++++++++++++ .../rust/src/scenarios/runtime/net/udp/udp_server.rs | 12 ++++++++++++ .../rust/src/scenarios/runtime/sleep/mod.rs | 12 ++++++++++++ .../rust/src/scenarios/runtime/sleep/sleep_basic.rs | 12 ++++++++++++ .../src/scenarios/runtime/worker/dedicated_worker.rs | 12 ++++++++++++ .../rust/src/scenarios/runtime/worker/mod.rs | 12 ++++++++++++ .../rust/src/scenarios/runtime/worker/num_workers.rs | 12 ++++++++++++ .../src/scenarios/runtime/worker/safety_worker.rs | 12 ++++++++++++ .../src/scenarios/runtime/worker/spawn_methods.rs | 12 ++++++++++++ .../src/scenarios/runtime/worker/thread_affinity.rs | 12 ++++++++++++ .../src/scenarios/runtime/worker/thread_priority.rs | 12 ++++++++++++ .../src/scenarios/runtime/worker/worker_basic.rs | 12 ++++++++++++ .../runtime/worker/worker_with_blocking_tasks.rs | 12 ++++++++++++ 140 files changed, 726 insertions(+), 318 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 125121c..bca2f97 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -34,7 +34,7 @@ bazel_dep(name = "platforms", version = "1.0.0") # S-CORE process rules bazel_dep(name = "score_bazel_platforms", version = "0.0.4") bazel_dep(name = "score_docs_as_code", version = "2.2.0") -bazel_dep(name = "score_tooling", version = "1.0.4") +bazel_dep(name = "score_tooling", version = "1.1.0") bazel_dep(name = "score_process", version = "1.2.1", dev_dependency = True) bazel_dep(name = "score_platform", version = "0.4.2", dev_dependency = True) # This is main score repo diff --git a/src/kyron-foundation/src/base/fast_rand.rs b/src/kyron-foundation/src/base/fast_rand.rs index fe02f59..bb39fe0 100644 --- a/src/kyron-foundation/src/base/fast_rand.rs +++ b/src/kyron-foundation/src/base/fast_rand.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* /// /// Minimal, very fast basic random num gen, suitable when enough is to have something random (no crypto suitable etc) diff --git a/src/kyron-foundation/src/base/mod.rs b/src/kyron-foundation/src/base/mod.rs index 236326d..ac99006 100644 --- a/src/kyron-foundation/src/base/mod.rs +++ b/src/kyron-foundation/src/base/mod.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,6 +9,6 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* pub mod fast_rand; diff --git a/src/kyron-foundation/src/cell/mod.rs b/src/kyron-foundation/src/cell/mod.rs index 0bab5fa..28deac8 100644 --- a/src/kyron-foundation/src/cell/mod.rs +++ b/src/kyron-foundation/src/cell/mod.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* #[cfg(loom)] pub use loom::cell::{ConstPtr, MutPtr, UnsafeCell}; diff --git a/src/kyron-foundation/src/containers/growable_vec.rs b/src/kyron-foundation/src/containers/growable_vec.rs index fc95061..71fee1c 100644 --- a/src/kyron-foundation/src/containers/growable_vec.rs +++ b/src/kyron-foundation/src/containers/growable_vec.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use crate::containers::vector_extension::VectorExtension; use ::core::{ diff --git a/src/kyron-foundation/src/containers/intrusive_linked_list.rs b/src/kyron-foundation/src/containers/intrusive_linked_list.rs index 6d8e5fe..052db6c 100644 --- a/src/kyron-foundation/src/containers/intrusive_linked_list.rs +++ b/src/kyron-foundation/src/containers/intrusive_linked_list.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use crate::cell::UnsafeCell; use core::marker::PhantomPinned; diff --git a/src/kyron-foundation/src/containers/mod.rs b/src/kyron-foundation/src/containers/mod.rs index 607cac7..73cd261 100644 --- a/src/kyron-foundation/src/containers/mod.rs +++ b/src/kyron-foundation/src/containers/mod.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* pub mod growable_vec; pub mod intrusive_linked_list; diff --git a/src/kyron-foundation/src/containers/mpmc_queue.rs b/src/kyron-foundation/src/containers/mpmc_queue.rs index 9e3c972..8d9e00e 100644 --- a/src/kyron-foundation/src/containers/mpmc_queue.rs +++ b/src/kyron-foundation/src/containers/mpmc_queue.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use ::core::mem::MaybeUninit; diff --git a/src/kyron-foundation/src/containers/queue.rs b/src/kyron-foundation/src/containers/queue.rs index 2fc7eee..deaf43a 100644 --- a/src/kyron-foundation/src/containers/queue.rs +++ b/src/kyron-foundation/src/containers/queue.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use crate::prelude::iceoryx2_bb_elementary_traits::{owning_pointer::OwningPointer, pointer_trait::PointerTrait}; use ::core::mem::{replace, MaybeUninit}; diff --git a/src/kyron-foundation/src/containers/reusable_objects.rs b/src/kyron-foundation/src/containers/reusable_objects.rs index a11a4e6..ab1d238 100644 --- a/src/kyron-foundation/src/containers/reusable_objects.rs +++ b/src/kyron-foundation/src/containers/reusable_objects.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use ::core::ops::Deref; use ::core::ptr::NonNull; diff --git a/src/kyron-foundation/src/containers/reusable_vec_pool.rs b/src/kyron-foundation/src/containers/reusable_vec_pool.rs index d97d148..a3de026 100644 --- a/src/kyron-foundation/src/containers/reusable_vec_pool.rs +++ b/src/kyron-foundation/src/containers/reusable_vec_pool.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* //! # ReusableVecPool //! diff --git a/src/kyron-foundation/src/containers/spmc_queue.rs b/src/kyron-foundation/src/containers/spmc_queue.rs index 62ee891..87e830f 100644 --- a/src/kyron-foundation/src/containers/spmc_queue.rs +++ b/src/kyron-foundation/src/containers/spmc_queue.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use ::core::alloc::Layout; use ::core::cell::UnsafeCell; diff --git a/src/kyron-foundation/src/containers/trigger_queue.rs b/src/kyron-foundation/src/containers/trigger_queue.rs index 451bd53..2f32aaf 100644 --- a/src/kyron-foundation/src/containers/trigger_queue.rs +++ b/src/kyron-foundation/src/containers/trigger_queue.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use crate::prelude::*; use crate::{prelude::FoundationAtomicBool, types::CommonErrors}; diff --git a/src/kyron-foundation/src/containers/vector_extension.rs b/src/kyron-foundation/src/containers/vector_extension.rs index f3061a3..f1cc797 100644 --- a/src/kyron-foundation/src/containers/vector_extension.rs +++ b/src/kyron-foundation/src/containers/vector_extension.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use iceoryx2_bb_memory::heap_allocator::HeapAllocator; diff --git a/src/kyron-foundation/src/lib.rs b/src/kyron-foundation/src/lib.rs index 76da1f1..fce9c01 100644 --- a/src/kyron-foundation/src/lib.rs +++ b/src/kyron-foundation/src/lib.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use ::core::alloc::Layout; use std::alloc::{self}; diff --git a/src/kyron-foundation/src/macros/mod.rs b/src/kyron-foundation/src/macros/mod.rs index 3be7596..790556a 100644 --- a/src/kyron-foundation/src/macros/mod.rs +++ b/src/kyron-foundation/src/macros/mod.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* /// /// `not_recoverable_error!` shall be used when the code is in position that it can only abort and there is no sense to return back to user diff --git a/src/kyron-foundation/src/prelude.rs b/src/kyron-foundation/src/prelude.rs index aff5fb1..7704a89 100644 --- a/src/kyron-foundation/src/prelude.rs +++ b/src/kyron-foundation/src/prelude.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* #[cfg(not(feature = "bazel_build_iceoryx2_qnx8"))] pub use iceoryx2_bb_container; diff --git a/src/kyron-foundation/src/sync/foundation_atomic.rs b/src/kyron-foundation/src/sync/foundation_atomic.rs index 177f9f8..2f09921 100644 --- a/src/kyron-foundation/src/sync/foundation_atomic.rs +++ b/src/kyron-foundation/src/sync/foundation_atomic.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* #[cfg(loom)] use loom::sync::atomic::*; diff --git a/src/kyron-foundation/src/sync/mod.rs b/src/kyron-foundation/src/sync/mod.rs index c114e1a..e390ed6 100644 --- a/src/kyron-foundation/src/sync/mod.rs +++ b/src/kyron-foundation/src/sync/mod.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,6 +9,6 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* pub mod foundation_atomic; diff --git a/src/kyron-foundation/src/threading/mod.rs b/src/kyron-foundation/src/threading/mod.rs index 67f41e0..0c2c8ec 100644 --- a/src/kyron-foundation/src/threading/mod.rs +++ b/src/kyron-foundation/src/threading/mod.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,6 +9,6 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* pub mod thread_wait_barrier; diff --git a/src/kyron-foundation/src/threading/thread_wait_barrier.rs b/src/kyron-foundation/src/threading/thread_wait_barrier.rs index 12d531f..3eef358 100644 --- a/src/kyron-foundation/src/threading/thread_wait_barrier.rs +++ b/src/kyron-foundation/src/threading/thread_wait_barrier.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use ::core::time::Duration; use std::sync::{Arc, Condvar, Mutex}; diff --git a/src/kyron-foundation/src/types.rs b/src/kyron-foundation/src/types.rs index 78c32bc..5dd7d7f 100644 --- a/src/kyron-foundation/src/types.rs +++ b/src/kyron-foundation/src/types.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* #[derive(Copy, Clone, Debug, PartialEq)] pub enum CommonErrors { diff --git a/src/kyron-macros/src/lib.rs b/src/kyron-macros/src/lib.rs index 76448fa..86c77de 100644 --- a/src/kyron-macros/src/lib.rs +++ b/src/kyron-macros/src/lib.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use proc_macro::TokenStream; use quote::quote; diff --git a/src/kyron-testing-macros/src/lib.rs b/src/kyron-testing-macros/src/lib.rs index 8ee0228..03ba05f 100644 --- a/src/kyron-testing-macros/src/lib.rs +++ b/src/kyron-testing-macros/src/lib.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use proc_macro::TokenStream; use quote::quote; diff --git a/src/kyron-testing/src/lib.rs b/src/kyron-testing/src/lib.rs index bfd01fa..13b5965 100644 --- a/src/kyron-testing/src/lib.rs +++ b/src/kyron-testing/src/lib.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* pub mod mock_fn; pub mod poller; diff --git a/src/kyron-testing/src/mock_fn.rs b/src/kyron-testing/src/mock_fn.rs index 0b20443..044e37b 100644 --- a/src/kyron-testing/src/mock_fn.rs +++ b/src/kyron-testing/src/mock_fn.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use kyron_foundation::containers::reusable_objects::ReusableObjectTrait; diff --git a/src/kyron-testing/src/poller.rs b/src/kyron-testing/src/poller.rs index a17a65c..783c86d 100644 --- a/src/kyron-testing/src/poller.rs +++ b/src/kyron-testing/src/poller.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use crate::waker::noop_waker; diff --git a/src/kyron-testing/src/prelude.rs b/src/kyron-testing/src/prelude.rs index 3faafb2..43293ff 100644 --- a/src/kyron-testing/src/prelude.rs +++ b/src/kyron-testing/src/prelude.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* pub use crate::mock_fn::*; pub use crate::poller::*; diff --git a/src/kyron-testing/src/waker.rs b/src/kyron-testing/src/waker.rs index cc94392..13f4d90 100644 --- a/src/kyron-testing/src/waker.rs +++ b/src/kyron-testing/src/waker.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use ::core::task::{RawWaker, RawWakerVTable, Waker}; use std::sync::Arc; diff --git a/src/kyron/examples/main_macro.rs b/src/kyron/examples/main_macro.rs index 088f1da..0aa8571 100644 --- a/src/kyron/examples/main_macro.rs +++ b/src/kyron/examples/main_macro.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use kyron::spawn; use kyron_foundation::prelude::{vector_extension::VectorExtension, *}; diff --git a/src/kyron/examples/mpmc.rs b/src/kyron/examples/mpmc.rs index b83c29b..3a87ac4 100644 --- a/src/kyron/examples/mpmc.rs +++ b/src/kyron/examples/mpmc.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use kyron::{runtime::*, spawn}; use kyron_foundation::prelude::*; diff --git a/src/kyron/examples/playground.rs b/src/kyron/examples/playground.rs index 32b45fc..a9a0711 100644 --- a/src/kyron/examples/playground.rs +++ b/src/kyron/examples/playground.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* #![allow(dead_code, unused_imports, unused_variables)] use kyron::futures::sleep; use kyron::ipc::iceoryx2::EventBuilderAsyncExt; diff --git a/src/kyron/examples/safety_task.rs b/src/kyron/examples/safety_task.rs index e2d7f34..a6d2957 100644 --- a/src/kyron/examples/safety_task.rs +++ b/src/kyron/examples/safety_task.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use kyron::prelude::*; use kyron::safety; diff --git a/src/kyron/examples/select.rs b/src/kyron/examples/select.rs index 238eb8e..55ecd86 100644 --- a/src/kyron/examples/select.rs +++ b/src/kyron/examples/select.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use kyron::{ prelude::*, diff --git a/src/kyron/src/channels/mod.rs b/src/kyron/src/channels/mod.rs index 53bcadf..d1e9ade 100644 --- a/src/kyron/src/channels/mod.rs +++ b/src/kyron/src/channels/mod.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* pub mod spmc_broadcast; pub mod spsc; diff --git a/src/kyron/src/channels/spmc_broadcast.rs b/src/kyron/src/channels/spmc_broadcast.rs index 515fb26..c8b6337 100644 --- a/src/kyron/src/channels/spmc_broadcast.rs +++ b/src/kyron/src/channels/spmc_broadcast.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use ::core::{future::Future, marker::PhantomData, task::Waker}; use std::sync::Arc; diff --git a/src/kyron/src/channels/spsc.rs b/src/kyron/src/channels/spsc.rs index 2bb18ce..9fa46f8 100644 --- a/src/kyron/src/channels/spsc.rs +++ b/src/kyron/src/channels/spsc.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use ::core::{future::Future, marker::PhantomData, task::Waker}; use kyron_foundation::{not_recoverable_error, prelude::*}; diff --git a/src/kyron/src/core/mod.rs b/src/kyron/src/core/mod.rs index 878d269..2bd0b84 100644 --- a/src/kyron/src/core/mod.rs +++ b/src/kyron/src/core/mod.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,6 +9,6 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* pub mod types; diff --git a/src/kyron/src/core/types.rs b/src/kyron/src/core/types.rs index 63789ef..f2dfff2 100644 --- a/src/kyron/src/core/types.rs +++ b/src/kyron/src/core/types.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use ::core::future::Future; use ::core::pin::Pin; diff --git a/src/kyron/src/futures/mod.rs b/src/kyron/src/futures/mod.rs index 3844795..9b66c4d 100644 --- a/src/kyron/src/futures/mod.rs +++ b/src/kyron/src/futures/mod.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* pub mod reusable_box_future; pub mod sleep; pub mod yield_now; diff --git a/src/kyron/src/futures/reusable_box_future.rs b/src/kyron/src/futures/reusable_box_future.rs index 25d6ebe..43195b8 100644 --- a/src/kyron/src/futures/reusable_box_future.rs +++ b/src/kyron/src/futures/reusable_box_future.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use ::core::alloc::Layout; use std::alloc::{self, dealloc}; diff --git a/src/kyron/src/futures/sleep.rs b/src/kyron/src/futures/sleep.rs index e6d9c34..dc7acd9 100644 --- a/src/kyron/src/futures/sleep.rs +++ b/src/kyron/src/futures/sleep.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use crate::{scheduler::driver::Drivers, time::clock::*}; use ::core::{future::Future, task::Waker, time::Duration}; diff --git a/src/kyron/src/futures/yield_now.rs b/src/kyron/src/futures/yield_now.rs index 421b7db..86ac1f6 100644 --- a/src/kyron/src/futures/yield_now.rs +++ b/src/kyron/src/futures/yield_now.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use ::core::future::Future; use ::core::pin::Pin; diff --git a/src/kyron/src/io/async_registration.rs b/src/kyron/src/io/async_registration.rs index 2300d78..7b68a87 100644 --- a/src/kyron/src/io/async_registration.rs +++ b/src/kyron/src/io/async_registration.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* // TODO: To be removed once used in IO APIs #![allow(dead_code)] diff --git a/src/kyron/src/io/bridgedfd.rs b/src/kyron/src/io/bridgedfd.rs index c89b251..18aa36f 100644 --- a/src/kyron/src/io/bridgedfd.rs +++ b/src/kyron/src/io/bridgedfd.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use core::task::{ready, Context, Poll}; use kyron_foundation::prelude::{error, CommonErrors}; diff --git a/src/kyron/src/io/driver.rs b/src/kyron/src/io/driver.rs index dae3ce4..264ab76 100644 --- a/src/kyron/src/io/driver.rs +++ b/src/kyron/src/io/driver.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* //! //! IO driver based on MIO selector that is able to integrate with async world. diff --git a/src/kyron/src/io/mod.rs b/src/kyron/src/io/mod.rs index 251f781..286d102 100644 --- a/src/kyron/src/io/mod.rs +++ b/src/kyron/src/io/mod.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* pub(crate) type AsyncSelector = crate::mio::selector::unix::poll::Selector; pub(crate) mod driver; diff --git a/src/kyron/src/io/read_buf.rs b/src/kyron/src/io/read_buf.rs index 97835c2..2c6c63c 100644 --- a/src/kyron/src/io/read_buf.rs +++ b/src/kyron/src/io/read_buf.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* // TODO: To be removed once used in IO APIs #![allow(dead_code)] diff --git a/src/kyron/src/io/traits.rs b/src/kyron/src/io/traits.rs index fd781ce..ffdee41 100644 --- a/src/kyron/src/io/traits.rs +++ b/src/kyron/src/io/traits.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* // TODO: To be removed once used in IO APIs #![allow(dead_code)] diff --git a/src/kyron/src/io/utils/mod.rs b/src/kyron/src/io/utils/mod.rs index f3d2323..6592f8f 100644 --- a/src/kyron/src/io/utils/mod.rs +++ b/src/kyron/src/io/utils/mod.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* pub mod read_future; pub mod write_future; diff --git a/src/kyron/src/io/utils/read_future.rs b/src/kyron/src/io/utils/read_future.rs index a9b9e77..e8a2f3c 100644 --- a/src/kyron/src/io/utils/read_future.rs +++ b/src/kyron/src/io/utils/read_future.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use crate::io::{AsyncRead, ReadBuf}; use core::{ diff --git a/src/kyron/src/io/utils/write_future.rs b/src/kyron/src/io/utils/write_future.rs index bd99734..c5be0ec 100644 --- a/src/kyron/src/io/utils/write_future.rs +++ b/src/kyron/src/io/utils/write_future.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use crate::{ error, diff --git a/src/kyron/src/ipc/iceoryx2/event.rs b/src/kyron/src/ipc/iceoryx2/event.rs index 501c3ca..24f23fc 100644 --- a/src/kyron/src/ipc/iceoryx2/event.rs +++ b/src/kyron/src/ipc/iceoryx2/event.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use core::time::Duration; diff --git a/src/kyron/src/ipc/iceoryx2/mod.rs b/src/kyron/src/ipc/iceoryx2/mod.rs index 8bd649b..b863cd0 100644 --- a/src/kyron/src/ipc/iceoryx2/mod.rs +++ b/src/kyron/src/ipc/iceoryx2/mod.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* #[cfg(not(feature = "bazel_build_iceoryx2_qnx8"))] pub use iceoryx2; diff --git a/src/kyron/src/ipc/mod.rs b/src/kyron/src/ipc/mod.rs index b45361c..7bc7351 100644 --- a/src/kyron/src/ipc/mod.rs +++ b/src/kyron/src/ipc/mod.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* #[cfg(feature = "iceoryx2-ipc")] pub mod iceoryx2; diff --git a/src/kyron/src/lib.rs b/src/kyron/src/lib.rs index b9bc47b..2561c05 100644 --- a/src/kyron/src/lib.rs +++ b/src/kyron/src/lib.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* //! # Kyron Crate //! diff --git a/src/kyron/src/macros/mod.rs b/src/kyron/src/macros/mod.rs index 3a8b4fb..4d49c78 100644 --- a/src/kyron/src/macros/mod.rs +++ b/src/kyron/src/macros/mod.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,6 +9,6 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* pub mod select; diff --git a/src/kyron/src/macros/select.rs b/src/kyron/src/macros/select.rs index 6e11480..81678fd 100644 --- a/src/kyron/src/macros/select.rs +++ b/src/kyron/src/macros/select.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* /// Awaits on multiple futures concurrently until any one finishes. /// diff --git a/src/kyron/src/mio/mod.rs b/src/kyron/src/mio/mod.rs index d4e5ad3..38e2612 100644 --- a/src/kyron/src/mio/mod.rs +++ b/src/kyron/src/mio/mod.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* pub mod net; pub mod poll; diff --git a/src/kyron/src/mio/net/mod.rs b/src/kyron/src/mio/net/mod.rs index 1ff1968..bf79072 100644 --- a/src/kyron/src/mio/net/mod.rs +++ b/src/kyron/src/mio/net/mod.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* pub mod tcp_listener; pub mod tcp_stream; diff --git a/src/kyron/src/mio/net/tcp_listener.rs b/src/kyron/src/mio/net/tcp_listener.rs index ec8e9cd..870ce27 100644 --- a/src/kyron/src/mio/net/tcp_listener.rs +++ b/src/kyron/src/mio/net/tcp_listener.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* #![allow(dead_code, unused, clippy::module_name_repetitions, clippy::upper_case_acronyms)] diff --git a/src/kyron/src/mio/net/tcp_stream.rs b/src/kyron/src/mio/net/tcp_stream.rs index 38e5405..9949aba 100644 --- a/src/kyron/src/mio/net/tcp_stream.rs +++ b/src/kyron/src/mio/net/tcp_stream.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* #![allow(dead_code, unused, clippy::module_name_repetitions, clippy::upper_case_acronyms)] diff --git a/src/kyron/src/mio/net/udp.rs b/src/kyron/src/mio/net/udp.rs index e9c4a4b..5324d5d 100644 --- a/src/kyron/src/mio/net/udp.rs +++ b/src/kyron/src/mio/net/udp.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* #![allow(dead_code, unused, clippy::module_name_repetitions, clippy::upper_case_acronyms)] diff --git a/src/kyron/src/mio/poll.rs b/src/kyron/src/mio/poll.rs index 1b2bb62..29ffe68 100644 --- a/src/kyron/src/mio/poll.rs +++ b/src/kyron/src/mio/poll.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use crate::mio::{ registry::Registry, diff --git a/src/kyron/src/mio/rawfd.rs b/src/kyron/src/mio/rawfd.rs index f99671d..ed17003 100644 --- a/src/kyron/src/mio/rawfd.rs +++ b/src/kyron/src/mio/rawfd.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use core::fmt::Debug; use std::os::fd::{AsRawFd, RawFd}; diff --git a/src/kyron/src/mio/registry.rs b/src/kyron/src/mio/registry.rs index ef6a0aa..8d4959e 100644 --- a/src/kyron/src/mio/registry.rs +++ b/src/kyron/src/mio/registry.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use crate::mio::types::{IoEventInterest, IoId, IoRegistryEntry, IoSelector, Result}; diff --git a/src/kyron/src/mio/selector/mod.rs b/src/kyron/src/mio/selector/mod.rs index bc29c70..2ca88dc 100644 --- a/src/kyron/src/mio/selector/mod.rs +++ b/src/kyron/src/mio/selector/mod.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* // Will be exposed only fox Unix like targets pub mod unix { diff --git a/src/kyron/src/mio/selector/unix/poll.rs b/src/kyron/src/mio/selector/unix/poll.rs index 8004b93..6c3b613 100644 --- a/src/kyron/src/mio/selector/unix/poll.rs +++ b/src/kyron/src/mio/selector/unix/poll.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use crate::mio::{ registry::Registry, diff --git a/src/kyron/src/mio/types.rs b/src/kyron/src/mio/types.rs index 12ac761..28dc6bb 100644 --- a/src/kyron/src/mio/types.rs +++ b/src/kyron/src/mio/types.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use crate::mio::registry::Registry; use core::{ diff --git a/src/kyron/src/net/mod.rs b/src/kyron/src/net/mod.rs index 733cb8d..a24868f 100644 --- a/src/kyron/src/net/mod.rs +++ b/src/kyron/src/net/mod.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* pub type NetResult = std::io::Result; diff --git a/src/kyron/src/net/tcp_listener.rs b/src/kyron/src/net/tcp_listener.rs index 543d338..870fb59 100644 --- a/src/kyron/src/net/tcp_listener.rs +++ b/src/kyron/src/net/tcp_listener.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use crate::{ io::{bridgedfd::BridgedFd, AsyncSelector}, diff --git a/src/kyron/src/net/tcp_stream.rs b/src/kyron/src/net/tcp_stream.rs index c920c92..3be6d44 100644 --- a/src/kyron/src/net/tcp_stream.rs +++ b/src/kyron/src/net/tcp_stream.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use core::{ pin::Pin, diff --git a/src/kyron/src/net/udp_socket.rs b/src/kyron/src/net/udp_socket.rs index 449fb11..0c78fd0 100644 --- a/src/kyron/src/net/udp_socket.rs +++ b/src/kyron/src/net/udp_socket.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use crate::{ io::{bridgedfd::BridgedFd, AsyncSelector}, diff --git a/src/kyron/src/net/utils.rs b/src/kyron/src/net/utils.rs index 19939cf..31110be 100644 --- a/src/kyron/src/net/utils.rs +++ b/src/kyron/src/net/utils.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use core::net::{AddrParseError, SocketAddr}; use std::io::ErrorKind; diff --git a/src/kyron/src/prelude.rs b/src/kyron/src/prelude.rs index c76f513..1ebc77a 100644 --- a/src/kyron/src/prelude.rs +++ b/src/kyron/src/prelude.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* pub use crate::core::types::UniqueWorkerId; pub use crate::runtime::*; diff --git a/src/kyron/src/runtime/mod.rs b/src/kyron/src/runtime/mod.rs index 794dc1a..aad1197 100644 --- a/src/kyron/src/runtime/mod.rs +++ b/src/kyron/src/runtime/mod.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* mod runtime_impl; diff --git a/src/kyron/src/runtime/runtime_impl.rs b/src/kyron/src/runtime/runtime_impl.rs index 7cf5c1a..eaf87ad 100644 --- a/src/kyron/src/runtime/runtime_impl.rs +++ b/src/kyron/src/runtime/runtime_impl.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use ::core::future::Future; use kyron_foundation::containers::Vec; diff --git a/src/kyron/src/safety.rs b/src/kyron/src/safety.rs index bf1fb18..88fa440 100644 --- a/src/kyron/src/safety.rs +++ b/src/kyron/src/safety.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use crate::{ core::types::{box_future, FutureBox, UniqueWorkerId}, diff --git a/src/kyron/src/scheduler/context.rs b/src/kyron/src/scheduler/context.rs index 2b1e28c..c664243 100644 --- a/src/kyron/src/scheduler/context.rs +++ b/src/kyron/src/scheduler/context.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use crate::core::types::BoxCustom; use crate::core::types::FutureBox; diff --git a/src/kyron/src/scheduler/driver.rs b/src/kyron/src/scheduler/driver.rs index da107a4..c88224a 100644 --- a/src/kyron/src/scheduler/driver.rs +++ b/src/kyron/src/scheduler/driver.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* // TODO: To be removed once used in IO APIs #[allow(dead_code)] diff --git a/src/kyron/src/scheduler/execution_engine.rs b/src/kyron/src/scheduler/execution_engine.rs index a3ffbfd..dd29eb9 100644 --- a/src/kyron/src/scheduler/execution_engine.rs +++ b/src/kyron/src/scheduler/execution_engine.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use ::core::time::Duration; use std::sync::Arc; diff --git a/src/kyron/src/scheduler/join_handle.rs b/src/kyron/src/scheduler/join_handle.rs index dbbd10b..69f5a36 100644 --- a/src/kyron/src/scheduler/join_handle.rs +++ b/src/kyron/src/scheduler/join_handle.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use kyron_foundation::prelude::*; use kyron_foundation::{not_recoverable_error, prelude::CommonErrors}; diff --git a/src/kyron/src/scheduler/mod.rs b/src/kyron/src/scheduler/mod.rs index 2ff4f88..46df6c5 100644 --- a/src/kyron/src/scheduler/mod.rs +++ b/src/kyron/src/scheduler/mod.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* pub mod context; pub(crate) mod driver; diff --git a/src/kyron/src/scheduler/safety_waker.rs b/src/kyron/src/scheduler/safety_waker.rs index 977c518..06dbf2c 100644 --- a/src/kyron/src/scheduler/safety_waker.rs +++ b/src/kyron/src/scheduler/safety_waker.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use super::task::async_task::*; use core::task::{RawWaker, RawWakerVTable, Waker}; diff --git a/src/kyron/src/scheduler/scheduler_mt.rs b/src/kyron/src/scheduler/scheduler_mt.rs index 82cdbe5..532481c 100644 --- a/src/kyron/src/scheduler/scheduler_mt.rs +++ b/src/kyron/src/scheduler/scheduler_mt.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use super::workers::worker_types::*; use crate::core::types::BoxInternal; diff --git a/src/kyron/src/scheduler/task/async_task.rs b/src/kyron/src/scheduler/task/async_task.rs index 0adc919..f7a835b 100644 --- a/src/kyron/src/scheduler/task/async_task.rs +++ b/src/kyron/src/scheduler/task/async_task.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use super::task_state::*; use crate::core::types::*; diff --git a/src/kyron/src/scheduler/task/mod.rs b/src/kyron/src/scheduler/task/mod.rs index 25ce757..3a8446c 100644 --- a/src/kyron/src/scheduler/task/mod.rs +++ b/src/kyron/src/scheduler/task/mod.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* pub mod async_task; pub mod task_context; diff --git a/src/kyron/src/scheduler/task/task_context.rs b/src/kyron/src/scheduler/task/task_context.rs index 1f2a45e..181ee5a 100644 --- a/src/kyron/src/scheduler/task/task_context.rs +++ b/src/kyron/src/scheduler/task/task_context.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use crate::{ core::types::TaskId, diff --git a/src/kyron/src/scheduler/task/task_state.rs b/src/kyron/src/scheduler/task/task_state.rs index a8dc305..522d677 100644 --- a/src/kyron/src/scheduler/task/task_state.rs +++ b/src/kyron/src/scheduler/task/task_state.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use kyron_foundation::sync::foundation_atomic::FoundationAtomicU32; /// TODO: For now no use-case for IDLE, I keep it. diff --git a/src/kyron/src/scheduler/waker.rs b/src/kyron/src/scheduler/waker.rs index e26444c..d357eed 100644 --- a/src/kyron/src/scheduler/waker.rs +++ b/src/kyron/src/scheduler/waker.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use kyron_foundation::prelude::FoundationAtomicPtr; diff --git a/src/kyron/src/scheduler/workers/dedicated_worker.rs b/src/kyron/src/scheduler/workers/dedicated_worker.rs index 7d5b3e9..5b75361 100644 --- a/src/kyron/src/scheduler/workers/dedicated_worker.rs +++ b/src/kyron/src/scheduler/workers/dedicated_worker.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use ::core::sync::atomic::Ordering; use kyron_foundation::{ containers::trigger_queue::TriggerQueueConsumer, diff --git a/src/kyron/src/scheduler/workers/mod.rs b/src/kyron/src/scheduler/workers/mod.rs index d1b655f..f7a4a2d 100644 --- a/src/kyron/src/scheduler/workers/mod.rs +++ b/src/kyron/src/scheduler/workers/mod.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* pub mod dedicated_worker; pub mod safety_worker; diff --git a/src/kyron/src/scheduler/workers/safety_worker.rs b/src/kyron/src/scheduler/workers/safety_worker.rs index c17bb0d..86369ee 100644 --- a/src/kyron/src/scheduler/workers/safety_worker.rs +++ b/src/kyron/src/scheduler/workers/safety_worker.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use ::core::sync::atomic::Ordering; use ::core::task::Context; use std::sync::Arc; diff --git a/src/kyron/src/scheduler/workers/worker.rs b/src/kyron/src/scheduler/workers/worker.rs index cb1c18f..0fbdcb5 100644 --- a/src/kyron/src/scheduler/workers/worker.rs +++ b/src/kyron/src/scheduler/workers/worker.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use ::core::task::Context; use core::time::Duration; diff --git a/src/kyron/src/scheduler/workers/worker_types.rs b/src/kyron/src/scheduler/workers/worker_types.rs index 971f9eb..2ad72ec 100644 --- a/src/kyron/src/scheduler/workers/worker_types.rs +++ b/src/kyron/src/scheduler/workers/worker_types.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use crate::core::types::UniqueWorkerId; use crate::io::driver::{IoDriver, IoDriverUnparker}; diff --git a/src/kyron/src/testing/mock.rs b/src/kyron/src/testing/mock.rs index 018afd1..135b0a0 100644 --- a/src/kyron/src/testing/mock.rs +++ b/src/kyron/src/testing/mock.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* #![allow(dead_code)] diff --git a/src/kyron/src/testing/mod.rs b/src/kyron/src/testing/mod.rs index c690590..fb831d0 100644 --- a/src/kyron/src/testing/mod.rs +++ b/src/kyron/src/testing/mod.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* #![allow(dead_code)] diff --git a/src/kyron/src/time/clock.rs b/src/kyron/src/time/clock.rs index 6231ff7..b8490ba 100644 --- a/src/kyron/src/time/clock.rs +++ b/src/kyron/src/time/clock.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use ::core::{ ops::{Add, Sub}, diff --git a/src/kyron/src/time/mod.rs b/src/kyron/src/time/mod.rs index 0289c0a..ec7979e 100644 --- a/src/kyron/src/time/mod.rs +++ b/src/kyron/src/time/mod.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use ::core::alloc::Layout; use ::core::time::Duration; diff --git a/src/kyron/src/time/wheel.rs b/src/kyron/src/time/wheel.rs index 802c5c5..63d791f 100644 --- a/src/kyron/src/time/wheel.rs +++ b/src/kyron/src/time/wheel.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use ::core::ptr::NonNull; use ::core::sync::atomic::Ordering; diff --git a/src/logging_tracing/src/lib.rs b/src/logging_tracing/src/lib.rs index 0b9fdd8..8cef2be 100644 --- a/src/logging_tracing/src/lib.rs +++ b/src/logging_tracing/src/lib.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* pub mod prelude; diff --git a/src/logging_tracing/src/log.rs b/src/logging_tracing/src/log.rs index c9eccd2..6687a2e 100644 --- a/src/logging_tracing/src/log.rs +++ b/src/logging_tracing/src/log.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* pub struct LogLibraryImpl {} diff --git a/src/logging_tracing/src/prelude.rs b/src/logging_tracing/src/prelude.rs index b68588a..0bcd9b4 100644 --- a/src/logging_tracing/src/prelude.rs +++ b/src/logging_tracing/src/prelude.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,6 +9,6 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* pub use crate::{LogAndTraceBuilder, LogMode, TraceScope}; diff --git a/src/logging_tracing/src/tracing.rs b/src/logging_tracing/src/tracing.rs index 04effd4..5fb5ea9 100644 --- a/src/logging_tracing/src/tracing.rs +++ b/src/logging_tracing/src/tracing.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use tracing::level_filters::LevelFilter; use tracing_subscriber::fmt; use tracing_subscriber::fmt::format; diff --git a/src/xtask/src/main.rs b/src/xtask/src/main.rs index a8a3006..1450c5d 100644 --- a/src/xtask/src/main.rs +++ b/src/xtask/src/main.rs @@ -1,5 +1,5 @@ -// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -9,7 +9,7 @@ // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* use std::collections::HashMap; use std::env; @@ -197,8 +197,8 @@ fn print_usage_and_exit() -> ! { exit(1); } -const REQUIRED_HEADER: &str = r#"// -// Copyright (c) 2025 Contributors to the Eclipse Foundation +const REQUIRED_HEADER: &str = r#"// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. @@ -208,7 +208,7 @@ const REQUIRED_HEADER: &str = r#"// // // // SPDX-License-Identifier: Apache-2.0 -// +// ******************************************************************************* "#; fn check_license_header() { diff --git a/tests/test_cases/BUILD b/tests/test_cases/BUILD index 5a51e3c..9b1dfe9 100644 --- a/tests/test_cases/BUILD +++ b/tests/test_cases/BUILD @@ -52,7 +52,7 @@ score_py_pytest( env = { "RUST_BACKTRACE": "1", }, - pytest_ini = ":pytest.ini", + pytest_config = ":pytest.ini", tags = [ "manual", ], @@ -75,7 +75,7 @@ score_py_pytest( env = { "RUST_BACKTRACE": "1", }, - pytest_ini = ":pytest.ini", + pytest_config = ":pytest.ini", tags = [ "manual", ], diff --git a/tests/test_scenarios/rust/src/internals/execution_barrier.rs b/tests/test_scenarios/rust/src/internals/execution_barrier.rs index ca4dc41..e2258ef 100644 --- a/tests/test_scenarios/rust/src/internals/execution_barrier.rs +++ b/tests/test_scenarios/rust/src/internals/execution_barrier.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* use kyron::JoinHandle; use kyron_foundation::threading::thread_wait_barrier::{ThreadReadyNotifier, ThreadWaitBarrier}; diff --git a/tests/test_scenarios/rust/src/internals/mod.rs b/tests/test_scenarios/rust/src/internals/mod.rs index 1abb37c..13c0726 100644 --- a/tests/test_scenarios/rust/src/internals/mod.rs +++ b/tests/test_scenarios/rust/src/internals/mod.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* pub mod execution_barrier; pub mod net_helper; pub mod runtime_helper; diff --git a/tests/test_scenarios/rust/src/internals/net_helper.rs b/tests/test_scenarios/rust/src/internals/net_helper.rs index 19f9ac1..20e236e 100644 --- a/tests/test_scenarios/rust/src/internals/net_helper.rs +++ b/tests/test_scenarios/rust/src/internals/net_helper.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* use kyron::net::{TcpListener, TcpStream, UdpSocket}; use serde::{de, Deserialize, Deserializer}; use serde_json::Value; diff --git a/tests/test_scenarios/rust/src/internals/runtime_helper.rs b/tests/test_scenarios/rust/src/internals/runtime_helper.rs index e60eabc..3670339 100644 --- a/tests/test_scenarios/rust/src/internals/runtime_helper.rs +++ b/tests/test_scenarios/rust/src/internals/runtime_helper.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* use kyron::core::types::UniqueWorkerId; use kyron::prelude::ThreadParameters as AsyncRtThreadParameters; use kyron::runtime::*; diff --git a/tests/test_scenarios/rust/src/internals/thread_params.rs b/tests/test_scenarios/rust/src/internals/thread_params.rs index 3ab1e13..9f5fff9 100644 --- a/tests/test_scenarios/rust/src/internals/thread_params.rs +++ b/tests/test_scenarios/rust/src/internals/thread_params.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* use std::mem::{size_of, MaybeUninit}; /// Get affinity of current thread. diff --git a/tests/test_scenarios/rust/src/main.rs b/tests/test_scenarios/rust/src/main.rs index 7385d52..b8458f5 100644 --- a/tests/test_scenarios/rust/src/main.rs +++ b/tests/test_scenarios/rust/src/main.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* mod internals; mod scenarios; diff --git a/tests/test_scenarios/rust/src/scenarios/basic/mod.rs b/tests/test_scenarios/rust/src/scenarios/basic/mod.rs index c8d1543..d1734ff 100644 --- a/tests/test_scenarios/rust/src/scenarios/basic/mod.rs +++ b/tests/test_scenarios/rust/src/scenarios/basic/mod.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* use test_scenarios_rust::scenario::{ScenarioGroup, ScenarioGroupImpl}; mod only_shutdown_sequence; diff --git a/tests/test_scenarios/rust/src/scenarios/basic/only_shutdown_sequence.rs b/tests/test_scenarios/rust/src/scenarios/basic/only_shutdown_sequence.rs index ce1e91e..8b63644 100644 --- a/tests/test_scenarios/rust/src/scenarios/basic/only_shutdown_sequence.rs +++ b/tests/test_scenarios/rust/src/scenarios/basic/only_shutdown_sequence.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* use crate::internals::runtime_helper::Runtime; use test_scenarios_rust::scenario::Scenario; use tracing::info; diff --git a/tests/test_scenarios/rust/src/scenarios/mod.rs b/tests/test_scenarios/rust/src/scenarios/mod.rs index 9a9acdf..ad03460 100644 --- a/tests/test_scenarios/rust/src/scenarios/mod.rs +++ b/tests/test_scenarios/rust/src/scenarios/mod.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* use test_scenarios_rust::scenario::{ScenarioGroup, ScenarioGroupImpl}; mod basic; diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/channel/mod.rs b/tests/test_scenarios/rust/src/scenarios/runtime/channel/mod.rs index dd2529a..59d72be 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/channel/mod.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/channel/mod.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* mod spmc_broadcast; mod spsc; diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/channel/spmc_broadcast.rs b/tests/test_scenarios/rust/src/scenarios/runtime/channel/spmc_broadcast.rs index 186e8de..fed5b84 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/channel/spmc_broadcast.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/channel/spmc_broadcast.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* use crate::internals::execution_barrier::RuntimeJoiner; use crate::internals::runtime_helper::Runtime; use test_scenarios_rust::scenario::Scenario; diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/channel/spsc.rs b/tests/test_scenarios/rust/src/scenarios/runtime/channel/spsc.rs index 62dd30d..70b9f15 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/channel/spsc.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/channel/spsc.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* use crate::internals::execution_barrier::RuntimeJoiner; use crate::internals::runtime_helper::Runtime; use test_scenarios_rust::scenario::Scenario; diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/execution_engine/mod.rs b/tests/test_scenarios/rust/src/scenarios/runtime/execution_engine/mod.rs index fc853f3..a980520 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/execution_engine/mod.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/execution_engine/mod.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* mod single_rt_multiple_exec_engine; use single_rt_multiple_exec_engine::SingleRtMultipleExecEngine; diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/execution_engine/single_rt_multiple_exec_engine.rs b/tests/test_scenarios/rust/src/scenarios/runtime/execution_engine/single_rt_multiple_exec_engine.rs index 67efbe3..05b0c38 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/execution_engine/single_rt_multiple_exec_engine.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/execution_engine/single_rt_multiple_exec_engine.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* use crate::internals::execution_barrier::RuntimeJoiner; use crate::internals::runtime_helper::Runtime; use kyron::runtime::RuntimeErrors; diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/mod.rs b/tests/test_scenarios/rust/src/scenarios/runtime/mod.rs index e0bf02b..5066323 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/mod.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/mod.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* mod channel; mod execution_engine; mod net; diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/net/mod.rs b/tests/test_scenarios/rust/src/scenarios/runtime/net/mod.rs index 5a7dfc8..7832c2b 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/net/mod.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/net/mod.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* mod tcp; mod udp; diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/mod.rs b/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/mod.rs index 8802c38..28a2789 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/mod.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/mod.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* mod server; mod tcp_listener; mod tcp_stream; diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/server.rs b/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/server.rs index a105b61..e8d8318 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/server.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/server.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* use crate::internals::net_helper::{create_tcp_listener, ConnectionParameters}; use crate::internals::runtime_helper::Runtime; use crate::scenarios::runtime::net::tcp::handle_connection_with_echo_response; diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/tcp_listener.rs b/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/tcp_listener.rs index b8c2aaa..927c13c 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/tcp_listener.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/tcp_listener.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* use crate::internals::net_helper::{create_tcp_listener, ConnectionParameters}; use crate::internals::runtime_helper::Runtime; use crate::scenarios::runtime::net::tcp::handle_connection_with_echo_response; diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/tcp_stream.rs b/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/tcp_stream.rs index 2dad056..193f414 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/tcp_stream.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/tcp_stream.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* use crate::internals::net_helper::{create_tcp_stream, ConnectionParameters}; use crate::internals::runtime_helper::Runtime; use kyron::io::{AsyncReadExt, AsyncWriteExt}; diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/net/udp/mod.rs b/tests/test_scenarios/rust/src/scenarios/runtime/net/udp/mod.rs index bb9503e..6d162ff 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/net/udp/mod.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/net/udp/mod.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* mod udp_client; mod udp_server; diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/net/udp/udp_client.rs b/tests/test_scenarios/rust/src/scenarios/runtime/net/udp/udp_client.rs index da1ff15..f3c11a3 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/net/udp/udp_client.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/net/udp/udp_client.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* use crate::internals::net_helper::{create_default_udp_client, ConnectionParameters}; use crate::internals::runtime_helper::Runtime; use kyron::{net::UdpSocket, spawn}; diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/net/udp/udp_server.rs b/tests/test_scenarios/rust/src/scenarios/runtime/net/udp/udp_server.rs index e9a4777..70ac131 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/net/udp/udp_server.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/net/udp/udp_server.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* use crate::internals::net_helper::{create_udp_listener, ConnectionParameters}; use crate::internals::runtime_helper::Runtime; use kyron::{net::UdpSocket, spawn}; diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/sleep/mod.rs b/tests/test_scenarios/rust/src/scenarios/runtime/sleep/mod.rs index 8d5261b..ea3bb89 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/sleep/mod.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/sleep/mod.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* mod sleep_basic; use test_scenarios_rust::scenario::{ScenarioGroup, ScenarioGroupImpl}; diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/sleep/sleep_basic.rs b/tests/test_scenarios/rust/src/scenarios/runtime/sleep/sleep_basic.rs index ade99a8..0d2f36a 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/sleep/sleep_basic.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/sleep/sleep_basic.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* use crate::internals::execution_barrier::RuntimeJoiner; use crate::internals::runtime_helper::Runtime; use test_scenarios_rust::scenario::Scenario; diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/worker/dedicated_worker.rs b/tests/test_scenarios/rust/src/scenarios/runtime/worker/dedicated_worker.rs index ed02b38..4ee7392 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/worker/dedicated_worker.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/worker/dedicated_worker.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* use crate::internals::execution_barrier::{MultiExecutionBarrier, RuntimeJoiner}; use crate::internals::runtime_helper::{DedicatedWorkerConfig, Runtime}; use crate::internals::thread_params::{current_thread_affinity, current_thread_priority_params, ThreadPriorityParams}; diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/worker/mod.rs b/tests/test_scenarios/rust/src/scenarios/runtime/worker/mod.rs index 9eb3188..f887421 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/worker/mod.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/worker/mod.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* mod dedicated_worker; mod num_workers; mod safety_worker; diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/worker/num_workers.rs b/tests/test_scenarios/rust/src/scenarios/runtime/worker/num_workers.rs index b56dd1f..77387f0 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/worker/num_workers.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/worker/num_workers.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* use crate::internals::execution_barrier::{MultiExecutionBarrier, RuntimeJoiner}; use crate::internals::runtime_helper::Runtime; use kyron::spawn; diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/worker/safety_worker.rs b/tests/test_scenarios/rust/src/scenarios/runtime/worker/safety_worker.rs index e503770..1bec286 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/worker/safety_worker.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/worker/safety_worker.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* use crate::internals::execution_barrier::RuntimeJoiner; use crate::internals::runtime_helper::Runtime; use crate::internals::thread_params::{current_thread_priority_params, ThreadPriorityParams}; diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/worker/spawn_methods.rs b/tests/test_scenarios/rust/src/scenarios/runtime/worker/spawn_methods.rs index c768a58..4bb156d 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/worker/spawn_methods.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/worker/spawn_methods.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* use crate::internals::execution_barrier::RuntimeJoiner; use crate::internals::runtime_helper::Runtime; use kyron::core::types::UniqueWorkerId; diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/worker/thread_affinity.rs b/tests/test_scenarios/rust/src/scenarios/runtime/worker/thread_affinity.rs index 329e25b..815d271 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/worker/thread_affinity.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/worker/thread_affinity.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* use crate::internals::execution_barrier::MultiExecutionBarrier; use crate::internals::execution_barrier::RuntimeJoiner; use crate::internals::runtime_helper::Runtime; diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/worker/thread_priority.rs b/tests/test_scenarios/rust/src/scenarios/runtime/worker/thread_priority.rs index b82b0eb..25f2984 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/worker/thread_priority.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/worker/thread_priority.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* use crate::internals::execution_barrier::MultiExecutionBarrier; use crate::internals::execution_barrier::RuntimeJoiner; use crate::internals::runtime_helper::Runtime; diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/worker/worker_basic.rs b/tests/test_scenarios/rust/src/scenarios/runtime/worker/worker_basic.rs index 1351f33..ef3d3ca 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/worker/worker_basic.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/worker/worker_basic.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* use crate::internals::execution_barrier::RuntimeJoiner; use crate::internals::runtime_helper::Runtime; use test_scenarios_rust::scenario::Scenario; diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/worker/worker_with_blocking_tasks.rs b/tests/test_scenarios/rust/src/scenarios/runtime/worker/worker_with_blocking_tasks.rs index b9f4970..aacbe9b 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/worker/worker_with_blocking_tasks.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/worker/worker_with_blocking_tasks.rs @@ -1,3 +1,15 @@ +// ******************************************************************************* +// Copyright (c) 2026 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache License Version 2.0 which is available at +// +// +// SPDX-License-Identifier: Apache-2.0 +// ******************************************************************************* use crate::internals::execution_barrier::{MultiExecutionBarrier, RuntimeJoiner}; use crate::internals::runtime_helper::Runtime; use test_scenarios_rust::scenario::Scenario; From 71192071b460314bc87ee592dde6a4be5c2e8925 Mon Sep 17 00:00:00 2001 From: Piotr Korkus Date: Mon, 9 Feb 2026 12:24:02 +0100 Subject: [PATCH 2/3] format rust with bazel --- MODULE.bazel | 1 + rustfmt.toml | 8 +- .../src/containers/growable_vec.rs | 4 +- .../src/containers/intrusive_linked_list.rs | 34 ++- src/kyron-foundation/src/containers/mod.rs | 3 +- .../src/containers/mpmc_queue.rs | 9 +- src/kyron-foundation/src/containers/queue.rs | 13 +- .../src/containers/reusable_objects.rs | 14 +- .../src/containers/spmc_queue.rs | 39 ++- .../src/containers/trigger_queue.rs | 6 +- .../src/threading/thread_wait_barrier.rs | 5 +- src/kyron-macros/src/lib.rs | 65 ++-- src/kyron-testing/src/mock_fn.rs | 55 +++- src/kyron-testing/src/poller.rs | 8 +- src/kyron/examples/main_macro.rs | 5 +- src/kyron/examples/mpmc.rs | 3 +- src/kyron/src/channels/spmc_broadcast.rs | 68 +++-- src/kyron/src/channels/spsc.rs | 43 ++- src/kyron/src/futures/reusable_box_future.rs | 13 +- src/kyron/src/futures/sleep.rs | 13 +- src/kyron/src/io/async_registration.rs | 188 +++++++++--- src/kyron/src/io/bridgedfd.rs | 33 +- src/kyron/src/io/driver.rs | 32 +- src/kyron/src/io/read_buf.rs | 6 +- src/kyron/src/io/utils/read_future.rs | 4 +- src/kyron/src/io/utils/write_future.rs | 2 +- src/kyron/src/ipc/iceoryx2/event.rs | 18 +- src/kyron/src/mio/net/tcp_listener.rs | 10 +- src/kyron/src/mio/net/tcp_stream.rs | 4 +- src/kyron/src/mio/poll.rs | 6 +- src/kyron/src/mio/rawfd.rs | 4 +- src/kyron/src/mio/registry.rs | 14 +- src/kyron/src/mio/selector/unix/poll.rs | 283 ++++++++++++++---- src/kyron/src/mio/types.rs | 6 +- src/kyron/src/net/tcp_listener.rs | 5 +- src/kyron/src/net/tcp_stream.rs | 6 +- src/kyron/src/net/udp_socket.rs | 8 +- src/kyron/src/net/utils.rs | 2 +- src/kyron/src/runtime/runtime_impl.rs | 37 ++- src/kyron/src/safety.rs | 5 +- src/kyron/src/scheduler/context.rs | 129 ++++++-- src/kyron/src/scheduler/driver.rs | 15 +- src/kyron/src/scheduler/execution_engine.rs | 71 ++++- src/kyron/src/scheduler/join_handle.rs | 83 +++-- src/kyron/src/scheduler/scheduler_mt.rs | 28 +- src/kyron/src/scheduler/task/async_task.rs | 73 +++-- src/kyron/src/scheduler/task/task_state.rs | 16 +- src/kyron/src/scheduler/waker.rs | 4 +- .../src/scheduler/workers/dedicated_worker.rs | 17 +- src/kyron/src/scheduler/workers/mod.rs | 7 +- .../src/scheduler/workers/safety_worker.rs | 22 +- src/kyron/src/scheduler/workers/worker.rs | 39 ++- .../src/scheduler/workers/worker_types.rs | 38 ++- src/kyron/src/testing/mock.rs | 51 +++- src/kyron/src/testing/mod.rs | 9 +- src/kyron/src/time/clock.rs | 12 +- src/kyron/src/time/mod.rs | 92 ++++-- src/kyron/src/time/wheel.rs | 13 +- src/logging_tracing/src/tracing.rs | 4 +- src/xtask/src/main.rs | 65 ++-- .../rust/src/internals/net_helper.rs | 4 +- .../rust/src/internals/runtime_helper.rs | 8 +- .../rust/src/internals/thread_params.rs | 6 +- .../runtime/channel/spmc_broadcast.rs | 56 ++-- .../src/scenarios/runtime/channel/spsc.rs | 32 +- .../rust/src/scenarios/runtime/net/mod.rs | 6 +- .../rust/src/scenarios/runtime/net/tcp/mod.rs | 17 +- .../src/scenarios/runtime/net/tcp/server.rs | 46 ++- .../scenarios/runtime/net/tcp/tcp_listener.rs | 17 +- .../scenarios/runtime/net/tcp/tcp_stream.rs | 34 ++- .../rust/src/scenarios/runtime/net/udp/mod.rs | 6 +- .../scenarios/runtime/net/udp/udp_client.rs | 45 ++- .../scenarios/runtime/net/udp/udp_server.rs | 14 +- .../rust/src/scenarios/runtime/sleep/mod.rs | 6 +- .../runtime/worker/dedicated_worker.rs | 102 +++++-- .../scenarios/runtime/worker/num_workers.rs | 7 +- .../scenarios/runtime/worker/safety_worker.rs | 56 +++- .../scenarios/runtime/worker/spawn_methods.rs | 87 ++++-- .../runtime/worker/thread_affinity.rs | 5 +- .../runtime/worker/thread_priority.rs | 5 +- .../worker/worker_with_blocking_tasks.rs | 18 +- 81 files changed, 1792 insertions(+), 655 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index bca2f97..7495676 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -35,6 +35,7 @@ bazel_dep(name = "platforms", version = "1.0.0") bazel_dep(name = "score_bazel_platforms", version = "0.0.4") bazel_dep(name = "score_docs_as_code", version = "2.2.0") bazel_dep(name = "score_tooling", version = "1.1.0") +bazel_dep(name = "score_rust_policies", version = "0.0.3") bazel_dep(name = "score_process", version = "1.2.1", dev_dependency = True) bazel_dep(name = "score_platform", version = "0.4.2", dev_dependency = True) # This is main score repo diff --git a/rustfmt.toml b/rustfmt.toml index 80ed606..40aad1c 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,6 +1,10 @@ # rust formatter rules. # check configuration fields here: https://rust-lang.github.io/rustfmt/?version=v1.6.0&search= - +edition = "2021" tab_spaces = 4 -max_width = 150 \ No newline at end of file +match_block_trailing_comma = true +max_width = 120 +force_explicit_abi = true +newline_style = "Unix" +use_field_init_shorthand = true diff --git a/src/kyron-foundation/src/containers/growable_vec.rs b/src/kyron-foundation/src/containers/growable_vec.rs index 71fee1c..a8bffc6 100644 --- a/src/kyron-foundation/src/containers/growable_vec.rs +++ b/src/kyron-foundation/src/containers/growable_vec.rs @@ -165,7 +165,9 @@ impl Into> for GrowableVec { // Reverse order for _ in 0..self.len() { - first.push(self.pop().unwrap()).expect("Failed to push value during conversion"); + first + .push(self.pop().unwrap()) + .expect("Failed to push value during conversion"); } let len = first.len(); diff --git a/src/kyron-foundation/src/containers/intrusive_linked_list.rs b/src/kyron-foundation/src/containers/intrusive_linked_list.rs index 052db6c..c83e53d 100644 --- a/src/kyron-foundation/src/containers/intrusive_linked_list.rs +++ b/src/kyron-foundation/src/containers/intrusive_linked_list.rs @@ -189,7 +189,7 @@ impl List { } else { false } - } + }, _ => { // If this is not the last item, we need to remove it from the list. let mut curr = self.head.as_ptr() as *const Link; @@ -208,7 +208,7 @@ impl List { } false - } + }, } } @@ -424,9 +424,18 @@ mod tests { } { - let item1 = TestItem { value: 1, link: Link::new() }; - let item2 = TestItem { value: 2, link: Link::new() }; - let item3 = TestItem { value: 3, link: Link::new() }; + let item1 = TestItem { + value: 1, + link: Link::new(), + }; + let item2 = TestItem { + value: 2, + link: Link::new(), + }; + let item3 = TestItem { + value: 3, + link: Link::new(), + }; let mut list: List = Default::default(); unsafe { list.push_back(&item1); @@ -443,9 +452,18 @@ mod tests { } { - let item1 = TestItem { value: 2, link: Link::new() }; - let item2 = TestItem { value: 2, link: Link::new() }; - let item3 = TestItem { value: 4, link: Link::new() }; + let item1 = TestItem { + value: 2, + link: Link::new(), + }; + let item2 = TestItem { + value: 2, + link: Link::new(), + }; + let item3 = TestItem { + value: 4, + link: Link::new(), + }; let item4 = TestItem { value: 16, link: Link::new(), diff --git a/src/kyron-foundation/src/containers/mod.rs b/src/kyron-foundation/src/containers/mod.rs index 73cd261..832b5fc 100644 --- a/src/kyron-foundation/src/containers/mod.rs +++ b/src/kyron-foundation/src/containers/mod.rs @@ -23,5 +23,6 @@ pub mod vector_extension; use crate::prelude::*; pub use iceoryx2_bb_container::vector::*; -pub type Vec = iceoryx2_bb_container::vector::PolymorphicVec<'static, T, iceoryx2_bb_memory::heap_allocator::HeapAllocator>; +pub type Vec = + iceoryx2_bb_container::vector::PolymorphicVec<'static, T, iceoryx2_bb_memory::heap_allocator::HeapAllocator>; pub use iceoryx2_bb_container::vector::Vector; diff --git a/src/kyron-foundation/src/containers/mpmc_queue.rs b/src/kyron-foundation/src/containers/mpmc_queue.rs index 8d9e00e..5a5071f 100644 --- a/src/kyron-foundation/src/containers/mpmc_queue.rs +++ b/src/kyron-foundation/src/containers/mpmc_queue.rs @@ -33,7 +33,14 @@ impl Iterator for QueuePtrIterator<'_, T> { return None; } - let item = unsafe { Some(self.guard.data.as_mut_ptr().add(self.guard.tail & (self.guard.capacity - 1))) }; + let item = unsafe { + Some( + self.guard + .data + .as_mut_ptr() + .add(self.guard.tail & (self.guard.capacity - 1)), + ) + }; self.guard.tail += 1; item } diff --git a/src/kyron-foundation/src/containers/queue.rs b/src/kyron-foundation/src/containers/queue.rs index deaf43a..6800783 100644 --- a/src/kyron-foundation/src/containers/queue.rs +++ b/src/kyron-foundation/src/containers/queue.rs @@ -57,7 +57,10 @@ impl Queue { } unsafe { - self.data.as_mut_ptr().add(self.head & (self.capacity - 1)).write(MaybeUninit::new(item)); + self.data + .as_mut_ptr() + .add(self.head & (self.capacity - 1)) + .write(MaybeUninit::new(item)); } self.head += 1; true @@ -68,7 +71,13 @@ impl Queue { return None; } - let item: T = unsafe { replace(&mut *self.data.as_mut_ptr().add(self.tail & (self.capacity - 1)), MaybeUninit::uninit()).assume_init() }; + let item: T = unsafe { + replace( + &mut *self.data.as_mut_ptr().add(self.tail & (self.capacity - 1)), + MaybeUninit::uninit(), + ) + .assume_init() + }; self.tail += 1; Some(item) diff --git a/src/kyron-foundation/src/containers/reusable_objects.rs b/src/kyron-foundation/src/containers/reusable_objects.rs index ab1d238..c8bf0cb 100644 --- a/src/kyron-foundation/src/containers/reusable_objects.rs +++ b/src/kyron-foundation/src/containers/reusable_objects.rs @@ -91,7 +91,7 @@ impl ReusableObjects { ::core::sync::atomic::Ordering::AcqRel, ::core::sync::atomic::Ordering::Acquire, ) { - Ok(_) => {} + Ok(_) => {}, Err(_) => return Err(CommonErrors::NoData), // next is not free yet, this is user problem now } @@ -162,7 +162,7 @@ impl Drop for ReusableObjects { ::core::sync::atomic::Ordering::AcqRel, ::core::sync::atomic::Ordering::Acquire, ) { - Ok(_) => {} + Ok(_) => {}, Err(actual) => unsafe { assert_eq!(actual, OBJECT_FREE); ::core::sync::atomic::fence(::core::sync::atomic::Ordering::SeqCst); // we will drop the value, so we must sync memory first so we call drop() on current object @@ -196,7 +196,7 @@ impl Drop for ReusableObject { ::core::sync::atomic::Ordering::AcqRel, ::core::sync::atomic::Ordering::Acquire, ) { - Ok(_) => {} + Ok(_) => {}, // Means that pool is dropped and we need to cleanup own memory Err(val) => { @@ -205,7 +205,7 @@ impl Drop for ReusableObject { self.this.storage.drop_in_place(); dealloc(self.this.storage.as_ptr() as *mut u8, Layout::new::()); } - } + }, } } } @@ -520,7 +520,9 @@ mod tests { let _ = handle.join().unwrap(); // Should be able to get the object back now - let obj = pool.next_object().expect("Should get object back after thread completes"); + let obj = pool + .next_object() + .expect("Should get object back after thread completes"); assert_eq!(obj.id, 0); assert_eq!(obj.value, 0); // Value should be cleared }); @@ -574,7 +576,7 @@ mod tests { let res = pool.next_object(); match res { Ok(v) => assert_eq!(0, *v), - Err(_) => {} + Err(_) => {}, } let _ = handle.join(); diff --git a/src/kyron-foundation/src/containers/spmc_queue.rs b/src/kyron-foundation/src/containers/spmc_queue.rs index 87e830f..ea1347b 100644 --- a/src/kyron-foundation/src/containers/spmc_queue.rs +++ b/src/kyron-foundation/src/containers/spmc_queue.rs @@ -158,7 +158,8 @@ impl SpmcStealQueue { pub fn new(size: u32) -> Self { assert!(size.is_power_of_two()); - let layout = Layout::array::>>(size as usize).expect("Invalid layout for array provided"); + let layout = + Layout::array::>>(size as usize).expect("Invalid layout for array provided"); let ptr = unsafe { alloc::alloc(layout) as *mut UnsafeCell> }; @@ -321,7 +322,9 @@ impl SpmcStealQueue { let head = self.head.load(Ordering::Relaxed); // Write only from current thread let tail = self.tail.load(Ordering::Acquire); // Access by multiple threads, so we want to make sure other threads have made visible all operations prior to Release - let num_possible = mpmc.len().min((self.capacity - Self::count_internal(head, tail)) as usize); + let num_possible = mpmc + .len() + .min((self.capacity - Self::count_internal(head, tail)) as usize); let mut num_items = 0; // Head index is only mutated when being here by single thread and is borrowed only once mutation finishes, so Cell req are fulfilled @@ -415,13 +418,15 @@ impl SpmcStealQueue { let next_real_tail = real_tail.wrapping_add(expected_steel_count); let expected_tail = Self::pack_tail(steal, next_real_tail); // For now steel is as it was, this will mark that we are stealing and prevent others to steal from us - let res = self.tail.compare_exchange(tail, expected_tail, Ordering::AcqRel, Ordering::Acquire); + let res = self + .tail + .compare_exchange(tail, expected_tail, Ordering::AcqRel, Ordering::Acquire); match res { Ok(_) => break (real_tail & self.access_mask, expected_steel_count), Err(actual) => { tail = actual; // Lets try again, as someone else was doing something to queue - } + }, } }; @@ -437,7 +442,9 @@ impl SpmcStealQueue { let dst_index = ((dst_head + i) & dst.access_mask) as usize; let dst_entry: &UnsafeCell> = &dst.data[dst_index]; - (*dst_entry.get()).as_mut_ptr().write((*src_entry.get()).as_ptr().read()); + (*dst_entry.get()) + .as_mut_ptr() + .write((*src_entry.get()).as_ptr().read()); } } @@ -447,12 +454,14 @@ impl SpmcStealQueue { let expected_tail = Self::pack_tail(real_tail, real_tail); // We are done, try align steal and tail to either our tail value or someone else if higher - let res = self.tail.compare_exchange(tail, expected_tail, Ordering::AcqRel, Ordering::SeqCst); + let res = self + .tail + .compare_exchange(tail, expected_tail, Ordering::AcqRel, Ordering::SeqCst); match res { Ok(_) => { return count; - } + }, Err(actual) => tail = actual, } } @@ -500,7 +509,7 @@ impl SpmcStealQueue { match res { Ok(_) => { break; - } + }, Err(actual) => tail = actual, } } @@ -810,7 +819,12 @@ mod tests { } let is_more_than_20 = remaining_in_queue > (vec_produced.len() as f32 * 0.2) as u32; - assert!(!is_more_than_20, "Was all {}, remaining {}", vec_produced.len(), remaining_in_queue); // We assume no more than 20% can stay in queue on producer thread + assert!( + !is_more_than_20, + "Was all {}, remaining {}", + vec_produced.len(), + remaining_in_queue + ); // We assume no more than 20% can stay in queue on producer thread // We may have some things in global queue now, we need to account them into comparison while let Some(v) = mpmc.pop() { @@ -889,7 +903,12 @@ mod tests { } let is_more_than_20 = remaining_in_queue > (worker1_vec.len() as f32 * 0.2) as u32; - assert!(!is_more_than_20, "Was all {}, remaining {}", vec_produced.len(), remaining_in_queue); // We assume no more than 20% can stay in queue on producer thread + assert!( + !is_more_than_20, + "Was all {}, remaining {}", + vec_produced.len(), + remaining_in_queue + ); // We assume no more than 20% can stay in queue on producer thread // We may have some things in global queue now, we need to account them into comparison while let Some(v) = mpmc.pop() { diff --git a/src/kyron-foundation/src/containers/trigger_queue.rs b/src/kyron-foundation/src/containers/trigger_queue.rs index 2f32aaf..0fb24e7 100644 --- a/src/kyron-foundation/src/containers/trigger_queue.rs +++ b/src/kyron-foundation/src/containers/trigger_queue.rs @@ -73,7 +73,9 @@ impl TriggerQueueConsumer { impl Drop for TriggerQueueConsumer { fn drop(&mut self) { - self.queue.has_consumer.store(false, ::core::sync::atomic::Ordering::SeqCst); + self.queue + .has_consumer + .store(false, ::core::sync::atomic::Ordering::SeqCst); } } @@ -347,7 +349,7 @@ mod tests { Ok(val) => { sum += val; received += 1; - } + }, Err(CommonErrors::Timeout) => continue, Err(_) => panic!("Unexpected error"), } diff --git a/src/kyron-foundation/src/threading/thread_wait_barrier.rs b/src/kyron-foundation/src/threading/thread_wait_barrier.rs index 3eef358..8dd7df9 100644 --- a/src/kyron-foundation/src/threading/thread_wait_barrier.rs +++ b/src/kyron-foundation/src/threading/thread_wait_barrier.rs @@ -98,7 +98,10 @@ impl ThreadWaitBarrier { /// * `Ok(())` - If all threads signaled readiness within the timeout. /// * `Err(CommonErrors::Timeout)` - If the timeout was reached before all threads signaled readiness. pub fn wait_for_all(&self, dur: Duration) -> Result<(), CommonErrors> { - let res = self.cv.wait_timeout_while(self.mtx.lock().unwrap(), dur, |cond| *cond > 0).unwrap(); + let res = self + .cv + .wait_timeout_while(self.mtx.lock().unwrap(), dur, |cond| *cond > 0) + .unwrap(); if res.1.timed_out() { Err(CommonErrors::Timeout) diff --git a/src/kyron-macros/src/lib.rs b/src/kyron-macros/src/lib.rs index 86c77de..61a763e 100644 --- a/src/kyron-macros/src/lib.rs +++ b/src/kyron-macros/src/lib.rs @@ -88,27 +88,27 @@ impl Parse for MacroArgs { "task_queue_size" => { let expr: Expr = input.parse()?; args.task_queue_size = Some(expr); - } + }, "worker_threads" => { let expr: Expr = input.parse()?; args.worker_threads = Some(expr); - } + }, "worker_thread_parameters" => { let tp: ThreadParams = parse_braced_thread_params(&input)?; args.worker_thread_parameters = Some(tp); - } + }, "safety_worker" => { let b: LitBool = input.parse()?; args.safety_worker = Some(b.value()); - } + }, "safety_worker_thread_parameters" => { let tp: ThreadParams = parse_braced_thread_params(&input)?; args.safety_worker_thread_parameters = Some(tp); - } + }, "safety_worker_task_queue_size" => { let expr: Expr = input.parse()?; args.safety_worker_task_queue_size = Some(expr); - } + }, "dedicated_workers" => { let inner; bracketed!(inner in input); @@ -127,14 +127,17 @@ impl Parse for MacroArgs { "id" => { let s: LitStr = content.parse()?; id_opt = Some(s); - } + }, "thread_parameters" => { let tp = parse_braced_thread_params(&&content)?; thread_params_opt = Some(tp); - } + }, other => { - return Err(syn::Error::new_spanned(key2, format!("Unknown key in dedicated_worker: {}", other))); - } + return Err(syn::Error::new_spanned( + key2, + format!("Unknown key in dedicated_worker: {}", other), + )); + }, } if content.peek(Token![,]) { @@ -142,7 +145,8 @@ impl Parse for MacroArgs { } } - let id = id_opt.ok_or_else(|| syn::Error::new_spanned(&key, "dedicated_worker missing required `id`"))?; + let id = id_opt + .ok_or_else(|| syn::Error::new_spanned(&key, "dedicated_worker missing required `id`"))?; args.dedicated_workers.push(DedicatedWorker { id, @@ -153,10 +157,13 @@ impl Parse for MacroArgs { let _c: Token![,] = inner.parse()?; } } - } + }, other => { - return Err(syn::Error::new_spanned(key, format!("Unknown attribute key: {}", other))); - } + return Err(syn::Error::new_spanned( + key, + format!("Unknown attribute key: {}", other), + )); + }, } // consume optional trailing comma @@ -184,11 +191,11 @@ fn parse_braced_thread_params(input: &ParseStream) -> Result { "priority" => { let v: Expr = content.parse()?; tp.priority = Some(v); - } + }, "scheduler_type" => { let s: LitStr = content.parse()?; tp.scheduler_type = Some(s); - } + }, "affinity" => { // parse bracketed list [0,1] let inner; @@ -202,14 +209,17 @@ fn parse_braced_thread_params(input: &ParseStream) -> Result { } } tp.affinity = Some(vals); - } + }, "stack_size" => { let v: Expr = content.parse()?; tp.stack_size = Some(v); - } + }, other => { - return Err(syn::Error::new_spanned(key, format!("Unknown key in thread parameters: {}", other))); - } + return Err(syn::Error::new_spanned( + key, + format!("Unknown key in thread parameters: {}", other), + )); + }, } if content.peek(Token![,]) { @@ -324,7 +334,7 @@ pub fn main(attr: TokenStream, item: TokenStream) -> TokenStream { eprintln!("*** Warning: Either priority or scheduler type is not configured for async worker, both attributes will be inherited from parent thread."); } thread_parameters_to_tokens(&tp, true) - } + }, None => quote! { /* no worker params */ }, }; @@ -340,7 +350,7 @@ pub fn main(attr: TokenStream, item: TokenStream) -> TokenStream { .into(); } quote! { #e } - } + }, None => quote! { 64 }, // default }; match args.safety_worker_thread_parameters { @@ -356,7 +366,7 @@ pub fn main(attr: TokenStream, item: TokenStream) -> TokenStream { ) .safety_worker_task_queue_size(#safety_worker_task_queue_size_ts) } - } + }, None => quote! { .enable_safety_worker(ThreadParameters::default()) .safety_worker_task_queue_size(#safety_worker_task_queue_size_ts) @@ -414,7 +424,7 @@ pub fn main(attr: TokenStream, item: TokenStream) -> TokenStream { .into(); } quote! { #e } - } + }, None => quote! { 256 }, // default }; @@ -427,7 +437,7 @@ pub fn main(attr: TokenStream, item: TokenStream) -> TokenStream { .into(); } quote! { #e } - } + }, None => quote! { 2 }, // default }; @@ -485,8 +495,9 @@ fn thread_parameters_to_tokens(tp: &ThreadParams, is_async_worker: bool) -> proc "RoundRobin" => quote! { kyron::scheduler::SchedulerType::RoundRobin }, "Other" => quote! { kyron::scheduler::SchedulerType::Other }, other => { - return syn::Error::new_spanned(scheduler_type, format!("Invalid scheduler_type: {}", other)).to_compile_error(); - } + return syn::Error::new_spanned(scheduler_type, format!("Invalid scheduler_type: {}", other)) + .to_compile_error(); + }, }; if is_async_worker { quote! { .thread_scheduler(#st) } diff --git a/src/kyron-testing/src/mock_fn.rs b/src/kyron-testing/src/mock_fn.rs index 044e37b..ed4d5da 100644 --- a/src/kyron-testing/src/mock_fn.rs +++ b/src/kyron-testing/src/mock_fn.rs @@ -189,7 +189,10 @@ impl MockFnBuilder { where F: FnMut(InType) -> OutType + Send + 'static, { - assert!(!self.is_will_repeatedly_set, "will_once() called after will_repeatedly()!"); + assert!( + !self.is_will_repeatedly_set, + "will_once() called after will_repeatedly()!" + ); { let mut info = self.info.lock().unwrap(); info.once.push_back(Box::new(f)); @@ -407,7 +410,10 @@ mod tests { #[test] fn test_call_count_equals_will_once_count() { - let mut mock = MockFnBuilder::<(), bool>::new().will_once_return(true).will_once_return(false).build(); + let mut mock = MockFnBuilder::<(), bool>::new() + .will_once_return(true) + .will_once_return(false) + .build(); assert!(mock.call(())); assert!(!mock.call(())); @@ -416,7 +422,10 @@ mod tests { #[test] #[should_panic] fn test_call_count_more_than_will_once_count_should_panic() { - let mut mock = MockFnBuilder::<(), bool>::new().will_once_return(true).will_once_return(false).build(); + let mut mock = MockFnBuilder::<(), bool>::new() + .will_once_return(true) + .will_once_return(false) + .build(); assert!(mock.call(())); assert!(!mock.call(())); @@ -426,7 +435,10 @@ mod tests { #[test] #[should_panic] fn test_panic_call_count_less_than_will_once_count_should_panic() { - let mut mock = MockFnBuilder::<(), bool>::new().will_once_return(true).will_once_return(false).build(); + let mut mock = MockFnBuilder::<(), bool>::new() + .will_once_return(true) + .will_once_return(false) + .build(); assert!(mock.call(())); } @@ -493,7 +505,12 @@ mod tests { #[test] fn test_err_with_times_after_will_repeatedly() { - let result = std::panic::catch_unwind(|| MockFnBuilder::<(), bool>::new().will_repeatedly_return(false).times(1).build()); + let result = std::panic::catch_unwind(|| { + MockFnBuilder::<(), bool>::new() + .will_repeatedly_return(false) + .times(1) + .build() + }); assert!(result.is_err()); } @@ -502,8 +519,14 @@ mod tests { fn test_sequence_execution_order_ok() { let seq = Sequence::new(); - let mut mock1 = MockFnBuilder::<(), bool>::new().in_sequence(&seq).will_once_return(true).build(); - let mut mock2 = MockFnBuilder::<(), bool>::new().in_sequence(&seq).will_once_return(false).build(); + let mut mock1 = MockFnBuilder::<(), bool>::new() + .in_sequence(&seq) + .will_once_return(true) + .build(); + let mut mock2 = MockFnBuilder::<(), bool>::new() + .in_sequence(&seq) + .will_once_return(false) + .build(); assert!(mock1.call(())); assert!(!mock2.call(())); @@ -514,8 +537,14 @@ mod tests { fn test_sequence_execution_order_err() { let seq = Sequence::new(); - let mut mock1 = MockFnBuilder::<(), bool>::new().in_sequence(&seq).will_once_return(true).build(); - let mut mock2 = MockFnBuilder::<(), bool>::new().in_sequence(&seq).will_once_return(false).build(); + let mut mock1 = MockFnBuilder::<(), bool>::new() + .in_sequence(&seq) + .will_once_return(true) + .build(); + let mut mock2 = MockFnBuilder::<(), bool>::new() + .in_sequence(&seq) + .will_once_return(false) + .build(); assert!(!mock2.call(())); assert!(mock1.call(())); @@ -538,8 +567,12 @@ mod tests { #[test] fn test_mockfn_intype_outtype() { let mut mock1 = MockFnBuilder::::new().will_once_invoke(|x| x + 1).build(); - let mut mock2 = MockFnBuilder::::new().will_once_invoke(|x| x.len()).build(); - let mut mock3 = MockFnBuilder::::new().will_repeatedly_invoke(|x| x * 2.0).build(); + let mut mock2 = MockFnBuilder::::new() + .will_once_invoke(|x| x.len()) + .build(); + let mut mock3 = MockFnBuilder::::new() + .will_repeatedly_invoke(|x| x * 2.0) + .build(); assert_eq!(mock1.call(1), 2); assert_eq!(mock2.call("Hello".into()), 5); diff --git a/src/kyron-testing/src/poller.rs b/src/kyron-testing/src/poller.rs index 783c86d..1ca31ac 100644 --- a/src/kyron-testing/src/poller.rs +++ b/src/kyron-testing/src/poller.rs @@ -26,10 +26,14 @@ pub struct TestingFuturePoller { impl TestingFuturePoller { pub fn new(future: impl Future + 'static + Send) -> TestingFuturePoller { - Self { future: Box::pin(future) } + Self { + future: Box::pin(future), + } } - pub fn from_boxed(boxed_future: Pin + 'static + Send>>) -> TestingFuturePoller { + pub fn from_boxed( + boxed_future: Pin + 'static + Send>>, + ) -> TestingFuturePoller { Self { future: boxed_future } } diff --git a/src/kyron/examples/main_macro.rs b/src/kyron/examples/main_macro.rs index 0aa8571..cacb30e 100644 --- a/src/kyron/examples/main_macro.rs +++ b/src/kyron/examples/main_macro.rs @@ -17,7 +17,10 @@ use kyron_foundation::prelude::{vector_extension::VectorExtension, *}; // A simple example for main macro usage with all default engine parameters #[kyron::main] async fn main() { - tracing_subscriber::fmt().with_target(false).with_max_level(Level::INFO).init(); + tracing_subscriber::fmt() + .with_target(false) + .with_max_level(Level::INFO) + .init(); let mut handles = Vec::new_in_global(10); diff --git a/src/kyron/examples/mpmc.rs b/src/kyron/examples/mpmc.rs index 3a87ac4..819e115 100644 --- a/src/kyron/examples/mpmc.rs +++ b/src/kyron/examples/mpmc.rs @@ -38,7 +38,8 @@ fn main() { .with_max_level(Level::DEBUG) .init(); - let (builder, _engine_id) = kyron::runtime::RuntimeBuilder::new().with_engine(ExecutionEngineBuilder::new().task_queue_size(8).workers(1)); + let (builder, _engine_id) = + kyron::runtime::RuntimeBuilder::new().with_engine(ExecutionEngineBuilder::new().task_queue_size(8).workers(1)); let mut runtime = builder.build().unwrap(); runtime.block_on(async { diff --git a/src/kyron/src/channels/spmc_broadcast.rs b/src/kyron/src/channels/spmc_broadcast.rs index c8b6337..405d51f 100644 --- a/src/kyron/src/channels/spmc_broadcast.rs +++ b/src/kyron/src/channels/spmc_broadcast.rs @@ -47,7 +47,9 @@ pub fn create_channel(max_num_of_receivers: u16) -> /// /// Creates Single Producer Multiple Consumer channel with [`DEFAULT_CHANNEL_SIZE`] capacity. Please keep in mind this is broadcast channel, so all `Receiver`s will receive the same value. /// -pub fn create_channel_default(max_num_of_receivers: u16) -> (Sender, Receiver) { +pub fn create_channel_default( + max_num_of_receivers: u16, +) -> (Sender, Receiver) { let mut chan = Arc::new(Channel::new(max_num_of_receivers as usize)); // Initialize the channel to set up the UniqueIndexSet after it is placed in an Arc. // Since UniqueIndexSet uses self-referential pointers, it must be initialized after being placed in Arc. @@ -235,14 +237,14 @@ impl Channel { let r = self.channels[c].send(value); match r { - Ok(_) => {} + Ok(_) => {}, Err(CommonErrors::GenericError) => { i += 1; if i == len { ret = Err(CommonErrors::GenericError) } - } + }, Err(_) => ret = r, } } @@ -250,7 +252,12 @@ impl Channel { ret } - fn receive(&self, index: usize, consumer: &mut spsc::queue::Consumer<'_, T, SIZE>, waker: Waker) -> Result { + fn receive( + &self, + index: usize, + consumer: &mut spsc::queue::Consumer<'_, T, SIZE>, + waker: Waker, + ) -> Result { self.channels[index].receive(consumer, waker) } @@ -287,18 +294,23 @@ unsafe impl Send for ReceiverFuture<'_, T, SIZE> {} impl Future for ReceiverFuture<'_, T, SIZE> { type Output = Option; - fn poll(mut self: ::core::pin::Pin<&mut Self>, cx: &mut ::core::task::Context<'_>) -> ::core::task::Poll { + fn poll( + mut self: ::core::pin::Pin<&mut Self>, + cx: &mut ::core::task::Context<'_>, + ) -> ::core::task::Poll { let res = match self.state { - FutureState::New | FutureState::Polled => self.parent.receive(&mut self.consumer, cx.waker().clone()).map_or_else( - |e| { - if e == CommonErrors::NoData { - FutureInternalReturn::polled() - } else { - FutureInternalReturn::ready(None) - } - }, - |v| FutureInternalReturn::ready(Some(v)), - ), + FutureState::New | FutureState::Polled => { + self.parent.receive(&mut self.consumer, cx.waker().clone()).map_or_else( + |e| { + if e == CommonErrors::NoData { + FutureInternalReturn::polled() + } else { + FutureInternalReturn::ready(None) + } + }, + |v| FutureInternalReturn::ready(Some(v)), + ) + }, FutureState::Finished => not_recoverable_error!("Cannot reuse future!"), }; @@ -427,11 +439,14 @@ mod tests { let (waker, _) = get_dummy_task_waker(); - let mut poller1 = TestingFuturePoller::new(async move { vec![r1.recv().await.unwrap(), r1.recv().await.unwrap()] }); + let mut poller1 = + TestingFuturePoller::new(async move { vec![r1.recv().await.unwrap(), r1.recv().await.unwrap()] }); - let mut poller2 = TestingFuturePoller::new(async move { vec![r2.recv().await.unwrap(), r2.recv().await.unwrap()] }); + let mut poller2 = + TestingFuturePoller::new(async move { vec![r2.recv().await.unwrap(), r2.recv().await.unwrap()] }); - let mut poller3 = TestingFuturePoller::new(async move { vec![r3.recv().await.unwrap(), r3.recv().await.unwrap()] }); + let mut poller3 = + TestingFuturePoller::new(async move { vec![r3.recv().await.unwrap(), r3.recv().await.unwrap()] }); let res1 = poller1.poll_with_waker(&waker); let res2 = poller2.poll_with_waker(&waker); @@ -495,9 +510,12 @@ mod tests { let (waker, _) = get_dummy_task_waker(); - let mut poller1 = TestingFuturePoller::new(async move { vec![r1.recv().await.unwrap(), r1.recv().await.unwrap()] }); - let mut poller2 = TestingFuturePoller::new(async move { vec![r2.recv().await.unwrap(), r2.recv().await.unwrap()] }); - let mut poller3 = TestingFuturePoller::new(async move { vec![r3.recv().await.unwrap(), r3.recv().await.unwrap()] }); + let mut poller1 = + TestingFuturePoller::new(async move { vec![r1.recv().await.unwrap(), r1.recv().await.unwrap()] }); + let mut poller2 = + TestingFuturePoller::new(async move { vec![r2.recv().await.unwrap(), r2.recv().await.unwrap()] }); + let mut poller3 = + TestingFuturePoller::new(async move { vec![r3.recv().await.unwrap(), r3.recv().await.unwrap()] }); let res1 = poller1.poll_with_waker(&waker); let res2 = poller2.poll_with_waker(&waker); @@ -519,7 +537,8 @@ mod tests { assert!(s.send(&2).is_ok()); // Should succeed for the remaining receiver let (waker, _) = get_dummy_task_waker(); - let mut poller = TestingFuturePoller::new(async move { vec![r2.recv().await.unwrap(), r2.recv().await.unwrap()] }); + let mut poller = + TestingFuturePoller::new(async move { vec![r2.recv().await.unwrap(), r2.recv().await.unwrap()] }); let res = poller.poll_with_waker(&waker); assert_poll_ready(res, vec![1, 2]); } @@ -540,7 +559,8 @@ mod tests { assert!(s.send(&2).is_ok()); // Should succeed for both receivers let (waker, _) = get_dummy_task_waker(); - let mut poller2 = TestingFuturePoller::new(async move { vec![r2.recv().await.unwrap(), r2.recv().await.unwrap()] }); + let mut poller2 = + TestingFuturePoller::new(async move { vec![r2.recv().await.unwrap(), r2.recv().await.unwrap()] }); let mut poller3 = TestingFuturePoller::new(async move { vec![r3.recv().await.unwrap()] }); let res2 = poller2.poll_with_waker(&waker); @@ -771,7 +791,7 @@ mod tests { assert_poll_ready(res1, input.clone()); match res2 { - ::core::task::Poll::Pending => {} + ::core::task::Poll::Pending => {}, _ => assert_poll_ready(res2, input.clone()), } }); diff --git a/src/kyron/src/channels/spsc.rs b/src/kyron/src/channels/spsc.rs index 9fa46f8..d7eba0d 100644 --- a/src/kyron/src/channels/spsc.rs +++ b/src/kyron/src/channels/spsc.rs @@ -141,7 +141,9 @@ impl Channel { } pub(super) fn sender_dropping(&self) { - let prev = self.connected_state.swap(SENDER_GONE, ::core::sync::atomic::Ordering::SeqCst); + let prev = self + .connected_state + .swap(SENDER_GONE, ::core::sync::atomic::Ordering::SeqCst); if prev == BOTH_IN { // if receiver is still there, notify him @@ -152,7 +154,8 @@ impl Channel { } pub(super) fn receiver_dropping(&self) { - self.connected_state.store(RECV_GONE, ::core::sync::atomic::Ordering::SeqCst); + self.connected_state + .store(RECV_GONE, ::core::sync::atomic::Ordering::SeqCst); let _ = self.waker_store.take(); } @@ -174,7 +177,8 @@ impl Channel { while consumer.pop().is_some() {} // Clear the bit to enable again - self.connected_state.fetch_and(!RECV_GONE, ::core::sync::atomic::Ordering::AcqRel); + self.connected_state + .fetch_and(!RECV_GONE, ::core::sync::atomic::Ordering::AcqRel); } } @@ -203,7 +207,11 @@ impl Channel { /// /// Safety: Upper layer needs to assure that there is no other `receive` caller at the same time, otherwise this will panic /// - pub(super) fn receive(&self, consumer: &mut spsc::queue::Consumer<'_, T, SIZE>, waker: Waker) -> Result { + pub(super) fn receive( + &self, + consumer: &mut spsc::queue::Consumer<'_, T, SIZE>, + waker: Waker, + ) -> Result { loop { let empty = self.queue.is_empty(); @@ -255,18 +263,23 @@ unsafe impl Send for ReceiverFuture<'_, T, SIZE> {} impl Future for ReceiverFuture<'_, T, SIZE> { type Output = Option; - fn poll(mut self: ::core::pin::Pin<&mut Self>, cx: &mut ::core::task::Context<'_>) -> ::core::task::Poll { + fn poll( + mut self: ::core::pin::Pin<&mut Self>, + cx: &mut ::core::task::Context<'_>, + ) -> ::core::task::Poll { let res = match self.state { - FutureState::New | FutureState::Polled => self.parent.receive(&mut self.consumer, cx.waker().clone()).map_or_else( - |e| { - if e == CommonErrors::NoData { - FutureInternalReturn::polled() - } else { - FutureInternalReturn::ready(None) - } - }, - |v| FutureInternalReturn::ready(Some(v)), - ), + FutureState::New | FutureState::Polled => { + self.parent.receive(&mut self.consumer, cx.waker().clone()).map_or_else( + |e| { + if e == CommonErrors::NoData { + FutureInternalReturn::polled() + } else { + FutureInternalReturn::ready(None) + } + }, + |v| FutureInternalReturn::ready(Some(v)), + ) + }, FutureState::Finished => not_recoverable_error!("Cannot reuse future!"), }; diff --git a/src/kyron/src/futures/reusable_box_future.rs b/src/kyron/src/futures/reusable_box_future.rs index 43195b8..c02cc93 100644 --- a/src/kyron/src/futures/reusable_box_future.rs +++ b/src/kyron/src/futures/reusable_box_future.rs @@ -125,7 +125,7 @@ impl ReusableBoxFuturePool { ::core::sync::atomic::Ordering::AcqRel, ::core::sync::atomic::Ordering::Acquire, ) { - Ok(_) => {} + Ok(_) => {}, Err(_) => return Err(CommonErrors::NoData), // next is not free yet, this is user problem now } @@ -189,7 +189,7 @@ impl Drop for ReusableBoxFuturePool { ::core::sync::atomic::Ordering::AcqRel, ::core::sync::atomic::Ordering::Acquire, ) { - Ok(_) => {} + Ok(_) => {}, Err(actual) => unsafe { assert_eq!(actual, FUTURE_FREE); @@ -231,7 +231,7 @@ impl Drop for ReusableBoxFuture { ::core::sync::atomic::Ordering::AcqRel, ::core::sync::atomic::Ordering::Acquire, ) { - Ok(_) => {} + Ok(_) => {}, // Means that pool is dropped probably and we need to cleanup own memory Err(val) => { @@ -239,7 +239,7 @@ impl Drop for ReusableBoxFuture { unsafe { dealloc(self.this.memory.as_ptr() as *mut u8, self.this.layout); } - } + }, } } } @@ -580,7 +580,10 @@ mod tests { drop(o); })); - assert_eq!("I am panicking....".to_owned(), *result.err().unwrap().downcast::<&str>().unwrap()); + assert_eq!( + "I am panicking....".to_owned(), + *result.err().unwrap().downcast::<&str>().unwrap() + ); assert!(panic_mock.was_dropped()); diff --git a/src/kyron/src/futures/sleep.rs b/src/kyron/src/futures/sleep.rs index dc7acd9..231995b 100644 --- a/src/kyron/src/futures/sleep.rs +++ b/src/kyron/src/futures/sleep.rs @@ -69,7 +69,10 @@ impl Sleep { impl Future for Sleep { type Output = (); - fn poll(mut self: ::core::pin::Pin<&mut Self>, cx: &mut ::core::task::Context<'_>) -> ::core::task::Poll { + fn poll( + mut self: ::core::pin::Pin<&mut Self>, + cx: &mut ::core::task::Context<'_>, + ) -> ::core::task::Poll { let res: FutureInternalReturn<()> = match self.state { // We need to round deadline to the nearest millisecond (round up always) to ensure that we are not awaken before the actual deadline. FutureState::New => match self.drivers.register(self.rounded_deadline(), cx.waker().clone()) { @@ -85,7 +88,7 @@ impl Future for Sleep { } else { FutureInternalReturn::polled() } - } + }, FutureState::Finished => not_recoverable_error!("Cannot be here, future is already finished"), }; @@ -119,7 +122,11 @@ mod tests { #[test] fn when_sleep_is_awaited_on_already_timeouted_time_its_ready_right_away() { let drv = TimeDriverMock { - mock: RefCell::new(MockFnBuilder::new_in_global(|_| Err(CommonErrors::AlreadyDone)).times(1).build()), + mock: RefCell::new( + MockFnBuilder::new_in_global(|_| Err(CommonErrors::AlreadyDone)) + .times(1) + .build(), + ), }; let sleep_future = Sleep::new(Duration::from_millis(20), Clock::now(), drv); diff --git a/src/kyron/src/io/async_registration.rs b/src/kyron/src/io/async_registration.rs index 7b68a87..ae882e3 100644 --- a/src/kyron/src/io/async_registration.rs +++ b/src/kyron/src/io/async_registration.rs @@ -90,7 +90,11 @@ impl AsyncRegistration { handle: IoDriverHandle, ) -> Result { let info = handle.add_io_source(mio, interest)?; - debug!("AsyncRegistration: Connecting {:?} with MIO object {:?}", info.tracing_id(), mio); + debug!( + "AsyncRegistration: Connecting {:?} with MIO object {:?}", + info.tracing_id(), + mio + ); Ok(AsyncRegistration { inner: info, handle }) } @@ -113,7 +117,7 @@ pub(crate) struct RegistrationInfo { #[derive(Default)] struct WakersCollection { // For Async trait there can be only one of them at a time and upper layers needs to ensure it - read: Option, // Slot used for AsyncRead, so polling API where there is no way to store anywhere waker + read: Option, // Slot used for AsyncRead, so polling API where there is no way to store anywhere waker write: Option, // Slot used for AsyncWrite, so polling API where there is no way to store anywhere waker // This is used for async API directly over ReadinessFuture which can hold a waker inside itself so we can put it into intrusive list. @@ -203,7 +207,11 @@ impl RegistrationInfo { let mut iter = offloader.iter_mut(); let mut wakers = self.wakers.lock().unwrap(); - trace!("{:?}: Waking up wakers for readiness: {:?}", self.tracing_id(), readiness); + trace!( + "{:?}: Waking up wakers for readiness: {:?}", + self.tracing_id(), + readiness + ); if readiness.is_readable() { if let Some(waker) = wakers.read.take() { @@ -271,7 +279,11 @@ impl RegistrationInfo { readiness.intersection(interest.into()) } - fn poll_register_interest(&self, interest: IoEventInterest, cx: &mut Context<'_>) -> FutureInternalReturn { + fn poll_register_interest( + &self, + interest: IoEventInterest, + cx: &mut Context<'_>, + ) -> FutureInternalReturn { let mut ready = self.is_ready(interest); // If we have something ready, we can return it immediately @@ -283,7 +295,11 @@ impl RegistrationInfo { let mut wakers = self.wakers.lock().unwrap(); // In this PR we only care about single wakers, lets choose one - let waker = if interest.is_readable() { &mut wakers.read } else { &mut wakers.write }; + let waker = if interest.is_readable() { + &mut wakers.read + } else { + &mut wakers.write + }; // Lets recheck if we are not ready while holding a lock ready = self.is_ready(interest); @@ -303,23 +319,25 @@ impl RegistrationInfo { where F: FnMut(ReadinessState) -> Option, { - match self.readiness_state.fetch_update(Ordering::AcqRel, Ordering::Acquire, |state| { - let mut typed_state = ReadinessState::from(state); - - match tick_op { - TickOp::Clear(tick) if tick != typed_state.tick() => return None, // We are not allowed to clear this tick as we would clear readiness for older state than it's now here. - - TickOp::Clear(_) => { - // Nothing to do, user will apply its closure - } - TickOp::Set => { - typed_state.increment_tick(); // Just increment the tick as new states comes + match self + .readiness_state + .fetch_update(Ordering::AcqRel, Ordering::Acquire, |state| { + let mut typed_state = ReadinessState::from(state); + + match tick_op { + TickOp::Clear(tick) if tick != typed_state.tick() => return None, // We are not allowed to clear this tick as we would clear readiness for older state than it's now here. + + TickOp::Clear(_) => { + // Nothing to do, user will apply its closure + }, + TickOp::Set => { + typed_state.increment_tick(); // Just increment the tick as new states comes + }, } - } - // TICKs are private, user does not touch it - f(typed_state).map(Into::::into) - }) { + // TICKs are private, user does not touch it + f(typed_state).map(Into::::into) + }) { Ok(v) => Into::::into(v), Err(v) => Into::::into(v), } @@ -425,7 +443,12 @@ impl ReadinessState { impl core::fmt::Debug for ReadinessState { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - write!(f, "ReadinessState(s: 0b{:b}, t: {})", self.extract_state(), self.extract_tick()) + write!( + f, + "ReadinessState(s: 0b{:b}, t: {})", + self.extract_state(), + self.extract_tick() + ) } } @@ -516,10 +539,10 @@ impl Future for ReadinessFuture<'_, S> { FutureInternalReturn::polled() } - } + }, } }) - } + }, FutureState::Polled => match self.registration.inner.is_ready(self.interest) { Some(readiness) => { let mut wakers = self.registration.inner.wakers.lock().unwrap(); @@ -529,12 +552,12 @@ impl Future for ReadinessFuture<'_, S> { }); FutureInternalReturn::ready(readiness) - } + }, _ => FutureInternalReturn::polled(), }, FutureState::Finished => { not_recoverable_error!(with self.registration.inner.tracing_id(), "Shall not poll finished future for ReadinessFuture") - } + }, }; self.state.borrow_mut().assign_and_propagate(state) @@ -544,7 +567,13 @@ impl Future for ReadinessFuture<'_, S> { impl Drop for ReadinessFuture<'_, S> { fn drop(&mut self) { self.list_item.with(|item| { - self.registration.inner.wakers.lock().unwrap().waiters.remove(unsafe { &*item }); + self.registration + .inner + .wakers + .lock() + .unwrap() + .waiters + .remove(unsafe { &*item }); }); } } @@ -778,7 +807,12 @@ mod tests { } impl IoRegistryEntry for ProxyMock { - fn register(&mut self, _registry: &Registry, _id: IoId, _interest: IoEventInterest) -> crate::mio::types::Result<()> { + fn register( + &mut self, + _registry: &Registry, + _id: IoId, + _interest: IoEventInterest, + ) -> crate::mio::types::Result<()> { Ok(()) } @@ -830,11 +864,21 @@ mod tests { Ok(()) } - fn register(&self, _fd: std::os::unix::prelude::RawFd, _id: IoId, _interest: IoEventInterest) -> crate::mio::types::Result<()> { + fn register( + &self, + _fd: std::os::unix::prelude::RawFd, + _id: IoId, + _interest: IoEventInterest, + ) -> crate::mio::types::Result<()> { Ok(()) } - fn reregister(&self, _fd: std::os::unix::prelude::RawFd, _id: IoId, _interest: IoEventInterest) -> crate::mio::types::Result<()> { + fn reregister( + &self, + _fd: std::os::unix::prelude::RawFd, + _id: IoId, + _interest: IoEventInterest, + ) -> crate::mio::types::Result<()> { Ok(()) } @@ -854,7 +898,12 @@ mod tests { #[derive(Clone, Debug)] pub struct IoMock {} impl IoRegistryEntry for IoMock { - fn register(&mut self, _registry: &Registry, _id: IoId, _interest: IoEventInterest) -> crate::mio::types::Result<()> { + fn register( + &mut self, + _registry: &Registry, + _id: IoId, + _interest: IoEventInterest, + ) -> crate::mio::types::Result<()> { Ok(()) } @@ -868,7 +917,10 @@ mod tests { } fn create_registration(interest: IoEventInterest) -> Arc> { - let handle = IoDriverHandle::::new(Registry::new(AsyncSelectorMock {}), Arc::new(Registrations::new(1024))); + let handle = IoDriverHandle::::new( + Registry::new(AsyncSelectorMock {}), + Arc::new(Registrations::new(1024)), + ); let mut mio = IoMock {}; Arc::new(AsyncRegistration::new_internal(&mut mio, interest, handle).unwrap()) } @@ -900,12 +952,17 @@ mod tests { crate::testing::mock::runtime::step(); assert_eq!(1, crate::testing::mock::runtime::remaining_tasks()); // We still have task not done - reg.inner.wake(ReadinessState::from_components(READINESS_STATE_WRITABLE as u16, 0)); // Make task ready + reg.inner + .wake(ReadinessState::from_components(READINESS_STATE_WRITABLE as u16, 0)); // Make task ready crate::testing::mock::runtime::step(); let ret_val = *result.lock().unwrap(); assert!(ret_val.is_ok(), "Expected Ok result, got: {:?}", ret_val); - assert!(ret_val.unwrap().is_writable(), "Expected writable state, got: {:?}", ret_val.unwrap()); + assert!( + ret_val.unwrap().is_writable(), + "Expected writable state, got: {:?}", + ret_val.unwrap() + ); } // Readable readiness @@ -916,12 +973,17 @@ mod tests { crate::testing::mock::runtime::step(); assert_eq!(1, crate::testing::mock::runtime::remaining_tasks()); // We still have task not done - reg.inner.wake(ReadinessState::from_components(READINESS_STATE_READABLE as u16, 0)); // Make task ready + reg.inner + .wake(ReadinessState::from_components(READINESS_STATE_READABLE as u16, 0)); // Make task ready crate::testing::mock::runtime::step(); let ret_val = *result.lock().unwrap(); assert!(ret_val.is_ok(), "Expected Ok result, got: {:?}", ret_val); - assert!(ret_val.unwrap().is_readable(), "Expected readable state, got: {:?}", ret_val.unwrap()); + assert!( + ret_val.unwrap().is_readable(), + "Expected readable state, got: {:?}", + ret_val.unwrap() + ); } // Multi readiness but readable @@ -940,7 +1002,11 @@ mod tests { let ret_val = *result.lock().unwrap(); assert!(ret_val.is_ok(), "Expected Ok result, got: {:?}", ret_val); - assert!(ret_val.unwrap().is_readable(), "Expected readable state, got: {:?}", ret_val.unwrap()); + assert!( + ret_val.unwrap().is_readable(), + "Expected readable state, got: {:?}", + ret_val.unwrap() + ); } // Multi readiness but writable @@ -959,7 +1025,11 @@ mod tests { let ret_val = *result.lock().unwrap(); assert!(ret_val.is_ok(), "Expected Ok result, got: {:?}", ret_val); - assert!(ret_val.unwrap().is_writable(), "Expected writable state, got: {:?}", ret_val.unwrap()); + assert!( + ret_val.unwrap().is_writable(), + "Expected writable state, got: {:?}", + ret_val.unwrap() + ); } } @@ -976,12 +1046,17 @@ mod tests { crate::testing::mock::runtime::step(); assert_eq!(1, crate::testing::mock::runtime::remaining_tasks()); // We still have task not done - reg.inner.wake(ReadinessState::from_components(READINESS_STATE_WRITABLE as u16, 0)); // Make task ready + reg.inner + .wake(ReadinessState::from_components(READINESS_STATE_WRITABLE as u16, 0)); // Make task ready crate::testing::mock::runtime::step(); let ret_val = *result.lock().unwrap(); assert!(ret_val.is_ok(), "Expected Ok result, got: {:?}", ret_val); - assert!(ret_val.unwrap().is_writable(), "Expected writable state, got: {:?}", ret_val.unwrap()); + assert!( + ret_val.unwrap().is_writable(), + "Expected writable state, got: {:?}", + ret_val.unwrap() + ); } // 2. Try again, but this time we are not waiting for anything @@ -993,7 +1068,11 @@ mod tests { let ret_val = *result.lock().unwrap(); assert!(ret_val.is_ok(), "Expected Ok result, got: {:?}", ret_val); - assert!(ret_val.unwrap().is_writable(), "Expected writable state, got: {:?}", ret_val.unwrap()); + assert!( + ret_val.unwrap().is_writable(), + "Expected writable state, got: {:?}", + ret_val.unwrap() + ); } } @@ -1010,12 +1089,17 @@ mod tests { crate::testing::mock::runtime::step(); assert_eq!(1, crate::testing::mock::runtime::remaining_tasks()); // We still have task not done - reg.inner.wake(ReadinessState::from_components(READINESS_STATE_WRITABLE as u16, 0)); // Make task ready + reg.inner + .wake(ReadinessState::from_components(READINESS_STATE_WRITABLE as u16, 0)); // Make task ready crate::testing::mock::runtime::step(); let ret_val = *result.lock().unwrap(); assert!(ret_val.is_ok(), "Expected Ok result, got: {:?}", ret_val); - assert!(ret_val.unwrap().is_writable(), "Expected writable state, got: {:?}", ret_val.unwrap()); + assert!( + ret_val.unwrap().is_writable(), + "Expected writable state, got: {:?}", + ret_val.unwrap() + ); // 2. Consume readiness reg.clear_readiness(ret_val.unwrap(), IoEventInterest::WRITABLE); @@ -1043,7 +1127,8 @@ mod tests { assert_eq!(1, crate::testing::mock::runtime::remaining_tasks()); // We still have task not done // 2. Other readiness is set, but not requested - reg.inner.wake(ReadinessState::from_components(READINESS_STATE_READABLE as u16, 0)); // Make task ready + reg.inner + .wake(ReadinessState::from_components(READINESS_STATE_READABLE as u16, 0)); // Make task ready // 3. So no progress on Future even after multiple calls crate::testing::mock::runtime::step(); @@ -1085,7 +1170,8 @@ mod tests { let mut ret = reg.poll_readiness(&mut ctx, IoEventInterest::READABLE); assert!(ret.is_pending(), "Expected pending state, got: {:?}", ret); - reg.inner.wake(ReadinessState::from_components(READINESS_STATE_READABLE as u16, 0)); // Make task ready + reg.inner + .wake(ReadinessState::from_components(READINESS_STATE_READABLE as u16, 0)); // Make task ready ret = reg.poll_readiness(&mut ctx, IoEventInterest::READABLE); @@ -1111,7 +1197,8 @@ mod tests { ret = reg.poll_readiness(&mut ctx, IoEventInterest::READABLE); assert!(ret.is_pending(), "Expected pending state, got: {:?}", ret); - reg.inner.wake(ReadinessState::from_components(READINESS_STATE_READABLE as u16, 0)); // Make task ready + reg.inner + .wake(ReadinessState::from_components(READINESS_STATE_READABLE as u16, 0)); // Make task ready ret = reg.poll_readiness(&mut ctx, IoEventInterest::READABLE); @@ -1146,7 +1233,8 @@ mod tests { let mut ret = reg.poll_readiness(&mut ctx, IoEventInterest::WRITABLE); assert!(ret.is_pending(), "Expected pending state, got: {:?}", ret); - reg.inner.wake(ReadinessState::from_components(READINESS_STATE_WRITABLE as u16, 0)); // Make task ready + reg.inner + .wake(ReadinessState::from_components(READINESS_STATE_WRITABLE as u16, 0)); // Make task ready ret = reg.poll_readiness(&mut ctx, IoEventInterest::WRITABLE); @@ -1172,7 +1260,8 @@ mod tests { ret = reg.poll_readiness(&mut ctx, IoEventInterest::WRITABLE); assert!(ret.is_pending(), "Expected pending state, got: {:?}", ret); - reg.inner.wake(ReadinessState::from_components(READINESS_STATE_WRITABLE as u16, 0)); // Make task ready + reg.inner + .wake(ReadinessState::from_components(READINESS_STATE_WRITABLE as u16, 0)); // Make task ready ret = reg.poll_readiness(&mut ctx, IoEventInterest::WRITABLE); @@ -1338,7 +1427,10 @@ mod tests { // Test union is commutative let state1 = create_state_with_bits(0x1111_0001); let state2 = create_state_with_bits(0x2222_0002); - assert_eq!(state1.union(state2).extract_state(), state2.union(state1).extract_state()); + assert_eq!( + state1.union(state2).extract_state(), + state2.union(state1).extract_state() + ); } #[test] diff --git a/src/kyron/src/io/bridgedfd.rs b/src/kyron/src/io/bridgedfd.rs index 18aa36f..60e9820 100644 --- a/src/kyron/src/io/bridgedfd.rs +++ b/src/kyron/src/io/bridgedfd.rs @@ -38,19 +38,28 @@ impl + core::fmt::Debug> BridgedFd { /// Creates MIO <-> async bridge for the given MIO object with READABLE and WRITABLE interests. pub fn new(mut mio_object: T) -> Result { let registration = AsyncRegistration::new(&mut mio_object)?; - Ok(BridgedFd { mio_object, registration }) + Ok(BridgedFd { + mio_object, + registration, + }) } /// Creates MIO <-> async bridge for the given MIO object with provided interest. pub fn new_with_interest(mut mio_object: T, interest: IoEventInterest) -> Result { let registration = AsyncRegistration::new_with_interest(&mut mio_object, interest)?; - Ok(BridgedFd { mio_object, registration }) + Ok(BridgedFd { + mio_object, + registration, + }) } /// Async interface to check readiness for the given interest. Keep in mind that this have to be registered before in `new` or `new_with_interest`. pub async fn ready(&self, interest: IoEventInterest) -> std::io::Result { - self.registration.request_readiness(interest).await.map_err(|e| e.into()) + self.registration + .request_readiness(interest) + .await + .map_err(|e| e.into()) } /// This bring ability to conduct synchronous, non blocking IO calls from upper layers with async behavior. @@ -68,15 +77,15 @@ impl + core::fmt::Debug> BridgedFd { match f(&self.mio_object) { Ok(v) => { return Ok(v); - } + }, Err(e) if e.kind() == std::io::ErrorKind::WouldBlock => { self.registration.clear_readiness(r, interest); continue; - } + }, Err(e) => { error!("Error reading from mio object via async: {}", e); return Err(e); - } + }, } } } @@ -108,16 +117,16 @@ impl + core::fmt::Debug> BridgedFd { // be explicitly `read` with WWouldBlock error to rearm notifications. This is pesimization for some of them like `epoll`. // This can be fixed if we coordinate some compile time flag between this place and AsyncSelector binding return Poll::Ready(Ok(())); - } + }, Err(e) if e.kind() == ErrorKind::WouldBlock => { // Clear readiness and let it run again and check readiness, if not ready, it will return Poll::Pending self.registration.clear_readiness(readiness, IoEventInterest::READABLE); - } + }, Err(e) => { error!("Error reading from mio object: {}", e); return Poll::Ready(Err(e)); - } + }, } } } @@ -138,16 +147,16 @@ impl + core::fmt::Debug> BridgedFd { // Same as in in read, we can only arm new events received by selector by writing till WouldBlock error. // TODO: Add here code that can detect if we use other selector than poll so we can do clear readiness logic here return Poll::Ready(Ok(n)); - } + }, Err(e) if e.kind() == ErrorKind::WouldBlock => { // Clear readiness and let it run again and check readiness, if not ready, it will return Poll::Pending self.registration.clear_readiness(readiness, IoEventInterest::WRITABLE); - } + }, Err(e) => { error!("Error writing using mio object: {}", e); return Poll::Ready(Err(e)); - } + }, } } } diff --git a/src/kyron/src/io/driver.rs b/src/kyron/src/io/driver.rs index 264ab76..285de5d 100644 --- a/src/kyron/src/io/driver.rs +++ b/src/kyron/src/io/driver.rs @@ -107,18 +107,25 @@ impl Registrations { let mut data = self.data.lock().unwrap(); let key = data.tracking.next_free_key().ok_or(CommonErrors::NoSpaceLeft)?; - Arc::get_mut(&mut item).unwrap().write(RegistrationInfo::new(key.value())); + Arc::get_mut(&mut item) + .unwrap() + .write(RegistrationInfo::new(key.value())); let item = unsafe { item.assume_init() }; let key_ret = data.tracking.insert(item.clone()).ok_or(CommonErrors::NoSpaceLeft)?; - debug_assert!(key == key_ret, "SlotMap returned key should be the same as provided in next_free_key"); + debug_assert!( + key == key_ret, + "SlotMap returned key should be the same as provided in next_free_key" + ); Ok(item) } fn schedule_registration_for_disposal(&self, key: SlotMapKey) { let mut data = self.data.lock().unwrap(); - data.waiting_release.push(key).expect("Failed to schedule registration for disposal"); // Vec cannot fail here as it has enough capacity + data.waiting_release + .push(key) + .expect("Failed to schedule registration for disposal"); // Vec cannot fail here as it has enough capacity self.pending_release_count.store(true, Ordering::Release); } @@ -156,7 +163,11 @@ impl IoDriverHandle { } /// Adds given IO source into the driver so it will be polled for events. - pub(crate) fn add_io_source(&self, source: &mut Source, interest: IoEventInterest) -> Result, CommonErrors> + pub(crate) fn add_io_source( + &self, + source: &mut Source, + interest: IoEventInterest, + ) -> Result, CommonErrors> where Source: IoRegistryEntry + core::fmt::Debug, { @@ -217,7 +228,8 @@ impl IoDriverHandle { // Right now we are sure that there is somewhere a next call to driver.poll, this source will not be considered. // Still it could be this source was considered int the poll happened during or little before deregister call so // we need to make sure that we keep it until next poll happens and remove before to release our reference count - self.async_registration.schedule_registration_for_disposal(SlotMapKey::new(key.unwrap())); + self.async_registration + .schedule_registration_for_disposal(SlotMapKey::new(key.unwrap())); } } @@ -261,7 +273,9 @@ impl IoDriver { /// Provides unparker that is able to unpark (wake up from poll) this IO driver from other threads. pub(crate) fn get_unparker(&self) -> IoDriverUnparker { - IoDriverUnparker { waker: self.waker.clone() } + IoDriverUnparker { + waker: self.waker.clone(), + } } /// Provides handle that is able to register and deregister IO sources in this driver. @@ -285,11 +299,11 @@ impl IoDriver { match binding.pool.poll(&mut binding.events, timeout) { Err(CommonErrors::Timeout) => { return Err(CommonErrors::Timeout); - } - Ok(_) => {} + }, + Ok(_) => {}, _ => { panic!("Generic error not handled!!!"); - } + }, } for event in binding.events.iter() { diff --git a/src/kyron/src/io/read_buf.rs b/src/kyron/src/io/read_buf.rs index 2c6c63c..d7d656c 100644 --- a/src/kyron/src/io/read_buf.rs +++ b/src/kyron/src/io/read_buf.rs @@ -149,7 +149,11 @@ impl<'a> ReadBuf<'a> { // Above assert ensures no overflow let filled_slice_uninit = &mut self.buf[self.filled..self.filled + len]; - unsafe { filled_slice_uninit.as_mut_ptr().copy_from_nonoverlapping(buf.as_ptr().cast(), buf.len()) }; + unsafe { + filled_slice_uninit + .as_mut_ptr() + .copy_from_nonoverlapping(buf.as_ptr().cast(), buf.len()) + }; self.filled += len; diff --git a/src/kyron/src/io/utils/read_future.rs b/src/kyron/src/io/utils/read_future.rs index e8a2f3c..4e18e3d 100644 --- a/src/kyron/src/io/utils/read_future.rs +++ b/src/kyron/src/io/utils/read_future.rs @@ -40,6 +40,8 @@ impl Future for ReadFuture<'_, R> { let Self { reader, buf } = &mut *self; let before = buf.filled().len(); - Pin::new(reader).poll_read(cx, buf).map(|_| Ok(buf.filled().len() - before)) + Pin::new(reader) + .poll_read(cx, buf) + .map(|_| Ok(buf.filled().len() - before)) } } diff --git a/src/kyron/src/io/utils/write_future.rs b/src/kyron/src/io/utils/write_future.rs index c5be0ec..b1f0bf1 100644 --- a/src/kyron/src/io/utils/write_future.rs +++ b/src/kyron/src/io/utils/write_future.rs @@ -53,7 +53,7 @@ impl Future for WriteFuture<'_, R> { }, FutureState::Finished => { not_recoverable_error!("Future polled after it finished!") - } + }, }) } } diff --git a/src/kyron/src/ipc/iceoryx2/event.rs b/src/kyron/src/ipc/iceoryx2/event.rs index 24f23fc..2f18ac1 100644 --- a/src/kyron/src/ipc/iceoryx2/event.rs +++ b/src/kyron/src/ipc/iceoryx2/event.rs @@ -83,7 +83,9 @@ where /// the error in detail. pub async fn wait_one(&self) -> Result { self.io - .async_call(IoEventInterest::READABLE, |raw_fd| raw_fd.io_call(|_| self.wait_one_internal())) + .async_call(IoEventInterest::READABLE, |raw_fd| { + raw_fd.io_call(|_| self.wait_one_internal()) + }) .await .map_err(|_| ListenerWaitError::InternalFailure) .and_then(|r| match r { @@ -107,18 +109,18 @@ where Ok(Ok(event)) => { callback(event); called_at_least_once = true; - } + }, Ok(Err(e)) => { warn!("Error waiting for iceoryx2 event: {}", e); return Ok(Err(e)); - } + }, // This means all samples are fetched out, we can exit Err(ref e) if e.kind() == std::io::ErrorKind::WouldBlock && called_at_least_once => { return Ok(Ok(())); - } + }, Err(e) => { return Err(e); - } + }, } } }) @@ -143,14 +145,14 @@ where } else { not_recoverable_error!(with err, "Other errors shall not be captured under Ok(None) returned from try_wait_one !"); } - } + }, Err(ListenerWaitError::InterruptSignal) => { continue; - } + }, Err(e) => { error!("Error waiting for iceoryx2 event: {}", e); return Ok(Err(e)); - } + }, } } } diff --git a/src/kyron/src/mio/net/tcp_listener.rs b/src/kyron/src/mio/net/tcp_listener.rs index 870ce27..3bfad03 100644 --- a/src/kyron/src/mio/net/tcp_listener.rs +++ b/src/kyron/src/mio/net/tcp_listener.rs @@ -45,10 +45,12 @@ impl TcpListenerBridge { } pub fn accept(&self) -> IoResult<(TcpStreamBridge, SocketAddr)> { - self.inner.io_call(|listener| listener.accept()).and_then(|(stream, addr)| { - let bridge = TcpStreamBridge::new(stream)?; - Ok((bridge, addr)) - }) + self.inner + .io_call(|listener| listener.accept()) + .and_then(|(stream, addr)| { + let bridge = TcpStreamBridge::new(stream)?; + Ok((bridge, addr)) + }) } pub fn local_addr(&self) -> IoResult { diff --git a/src/kyron/src/mio/net/tcp_stream.rs b/src/kyron/src/mio/net/tcp_stream.rs index 9949aba..def2010 100644 --- a/src/kyron/src/mio/net/tcp_stream.rs +++ b/src/kyron/src/mio/net/tcp_stream.rs @@ -41,7 +41,9 @@ impl TcpStreamBridge { pub(crate) fn new(s: std::net::TcpStream) -> IoResult { s.set_nonblocking(true)?; - Ok(TcpStreamBridge { inner: T::IoProxy::new(s) }) + Ok(TcpStreamBridge { + inner: T::IoProxy::new(s), + }) } pub(crate) fn connect(addr: SocketAddr) -> IoResult { diff --git a/src/kyron/src/mio/poll.rs b/src/kyron/src/mio/poll.rs index 29ffe68..2b30988 100644 --- a/src/kyron/src/mio/poll.rs +++ b/src/kyron/src/mio/poll.rs @@ -33,7 +33,11 @@ impl Poll { /// Wait on events on the registered I/O resources using the chosen selector. /// /// `timeout` specifies the maximum time to wait for an event. If `None` is provided, it will wait indefinitely. - pub fn poll(&self, events: &mut Container, timeout: Option) -> Result<()> { + pub fn poll( + &self, + events: &mut Container, + timeout: Option, + ) -> Result<()> { events.clear(); self.registry.selector.select(events, timeout) } diff --git a/src/kyron/src/mio/rawfd.rs b/src/kyron/src/mio/rawfd.rs index ed17003..9f6e619 100644 --- a/src/kyron/src/mio/rawfd.rs +++ b/src/kyron/src/mio/rawfd.rs @@ -46,7 +46,9 @@ impl RawFdBridge { /// behavior that the author is probably not aware of. /// pub fn from(raw: RawFd) -> Result { - Ok(RawFdBridge { inner: T::IoProxy::new(raw) }) + Ok(RawFdBridge { + inner: T::IoProxy::new(raw), + }) } /// Consumes self and returns the underlying RawFd. diff --git a/src/kyron/src/mio/registry.rs b/src/kyron/src/mio/registry.rs index 8d4959e..424a5b8 100644 --- a/src/kyron/src/mio/registry.rs +++ b/src/kyron/src/mio/registry.rs @@ -23,11 +23,21 @@ impl Registry { Registry { selector } } - pub fn register>(&self, source: &mut Source, id: IoId, interest: IoEventInterest) -> Result<()> { + pub fn register>( + &self, + source: &mut Source, + id: IoId, + interest: IoEventInterest, + ) -> Result<()> { source.register(self, id, interest) } - pub fn reregister>(&self, source: &mut Source, id: IoId, interest: IoEventInterest) -> Result<()> { + pub fn reregister>( + &self, + source: &mut Source, + id: IoId, + interest: IoEventInterest, + ) -> Result<()> { source.reregister(id, interest) } diff --git a/src/kyron/src/mio/selector/unix/poll.rs b/src/kyron/src/mio/selector/unix/poll.rs index 6c3b613..ba6bf2c 100644 --- a/src/kyron/src/mio/selector/unix/poll.rs +++ b/src/kyron/src/mio/selector/unix/poll.rs @@ -13,14 +13,16 @@ use crate::mio::{ registry::Registry, - types::{IoCall, IoEvent, IoEventInterest, IoId, IoRegistryEntry, IoResult, IoSelector, IoSelectorEventContainer, Result}, + types::{ + IoCall, IoEvent, IoEventInterest, IoId, IoRegistryEntry, IoResult, IoSelector, IoSelectorEventContainer, Result, + }, }; use core::time::Duration; use iceoryx2_bb_container::flatmap::FlatMap; use kyron_foundation::{containers::vector_extension::VectorExtension, not_recoverable_error, prelude::*}; use libc::{ - close, fcntl, pipe, poll, pollfd, read, write, EAGAIN, EINTR, FD_CLOEXEC, F_SETFD, F_SETFL, O_CLOEXEC, O_NONBLOCK, POLLERR, POLLHUP, POLLIN, - POLLOUT, POLLPRI, + close, fcntl, pipe, poll, pollfd, read, write, EAGAIN, EINTR, FD_CLOEXEC, F_SETFD, F_SETFL, O_CLOEXEC, O_NONBLOCK, + POLLERR, POLLHUP, POLLIN, POLLOUT, POLLPRI, }; use std::{ ffi, @@ -43,8 +45,13 @@ impl Selector { pub fn new(fd_capacity: usize) -> Self { let mut fds = Fds::new(1 + fd_capacity); let poll_waker = InternalWaker::new().expect("Failed to create the internal InternalWaker"); - fds.add(poll_waker.read_fd, IoId::new(u64::default()), IoEventInterest::READABLE, true) - .expect("Failed to add the InternalWaker"); + fds.add( + poll_waker.read_fd, + IoId::new(u64::default()), + IoEventInterest::READABLE, + true, + ) + .expect("Failed to add the InternalWaker"); Selector { inner: Arc::new(Inner { @@ -208,7 +215,9 @@ impl SelectWaker { impl Drop for SelectWaker { fn drop(&mut self) { - self.1.deregister(self.0.read_fd).expect("Failed to deregister SelectWaker"); + self.1 + .deregister(self.0.read_fd) + .expect("Failed to deregister SelectWaker"); } } @@ -268,7 +277,7 @@ impl InternalWaker { match res { 0 => { not_recoverable_error!("There shall be no write with 0 bytes written, some error happened"); - } + }, -1 => { let err = std::io::Error::last_os_error().raw_os_error().unwrap(); match err { @@ -278,7 +287,7 @@ impl InternalWaker { EINTR => (), // Retry. _ => not_recoverable_error!(with err, "InternalWaker write failed"), } - } + }, _ => break, // Successfully wrote some data. } } @@ -298,7 +307,7 @@ impl InternalWaker { e => { warn!("InternalWaker read failed with error {}", e); break; - } + }, } } else { // All data has been read. @@ -354,8 +363,12 @@ impl Fds { } // None of these can fail. Capacity was verified above. - self.fd_to_index.insert(fd, self.infos.len()).expect("Failed to add file descriptor"); - self.infos.push(FdInfo { id, is_waker }).expect("Failed to add file descriptor info"); + self.fd_to_index + .insert(fd, self.infos.len()) + .expect("Failed to add file descriptor"); + self.infos + .push(FdInfo { id, is_waker }) + .expect("Failed to add file descriptor info"); self.pollfds .push(pollfd { fd, @@ -483,7 +496,11 @@ impl Inner { } } - fn select(&self, events: &mut Container, timeout: Option) -> Result<()> { + fn select( + &self, + events: &mut Container, + timeout: Option, + ) -> Result<()> { let timeout = timeout.map(|d| d.as_millis() as i32).unwrap_or(-1); let mut fds = self.fds.lock().unwrap(); @@ -493,16 +510,24 @@ impl Inner { fds = self.accesses_finished.wait(fds).unwrap(); } - let poll_result: i32 = unsafe { poll(fds.pollfds.as_mut_slice().as_mut_ptr(), fds.pollfds.len() as libc::nfds_t, timeout) }; + let poll_result: i32 = unsafe { + poll( + fds.pollfds.as_mut_slice().as_mut_ptr(), + fds.pollfds.len() as libc::nfds_t, + timeout, + ) + }; match poll_result { -1 => { let err = std::io::Error::last_os_error().raw_os_error().unwrap(); match err { libc::EINTR => continue, - _ => not_recoverable_error!(with err, "Poll failed with error: This is a bug in implementation!"), + _ => { + not_recoverable_error!(with err, "Poll failed with error: This is a bug in implementation!") + }, } - } + }, 0 => break Err(CommonErrors::Timeout), _ => { // If there's an event only for the internal poll waker, @@ -561,7 +586,7 @@ impl Inner { } return Ok(()); - } + }, } } } @@ -711,7 +736,10 @@ mod tests { // When changing this, look into select implementation as it assumes the internal waker is at index 0. assert_eq!(selector.inner.fds.lock().unwrap().pollfds.len(), 1); - assert_eq!(selector.inner.poll_waker.read_fd, selector.inner.fds.lock().unwrap().pollfds[0].fd); + assert_eq!( + selector.inner.poll_waker.read_fd, + selector.inner.fds.lock().unwrap().pollfds[0].fd + ); } #[test] @@ -719,7 +747,9 @@ mod tests { let (read_fd, write_fd) = create_pipe(); let id = 1; let selector = Selector::new(8); - selector.register(read_fd, IoId::new(id), IoEventInterest::READABLE).unwrap(); + selector + .register(read_fd, IoId::new(id), IoEventInterest::READABLE) + .unwrap(); let (begin_sync, _, join_handle) = create_thread(move || { let mut events = Vec::::new_in_global(8); @@ -731,10 +761,16 @@ mod tests { // Make the pipe readable. let data = 1_u8; - assert_eq!(unsafe { write(write_fd, &data as *const u8 as *const ffi::c_void, 1_usize) }, 1_isize); + assert_eq!( + unsafe { write(write_fd, &data as *const u8 as *const ffi::c_void, 1_usize) }, + 1_isize + ); let events = join_handle.join().unwrap(); - assert_eq!( as IoSelectorEventContainer>::len(&events), 1); + assert_eq!( + as IoSelectorEventContainer>::len(&events), + 1 + ); assert_eq!(events[0].id(), IoId::new(id)); assert!(events[0].is_readable()); assert!(!events[0].is_writable()); @@ -745,7 +781,9 @@ mod tests { let (read_fd, write_fd) = create_pipe(); let id = 1; let selector = Selector::new(8); - selector.register(write_fd, IoId::new(id), IoEventInterest::WRITABLE).unwrap(); + selector + .register(write_fd, IoId::new(id), IoEventInterest::WRITABLE) + .unwrap(); // Make the pipe not writable. write_until_blocking(write_fd); @@ -762,7 +800,10 @@ mod tests { read_until_blocking(read_fd); let events = join_handle.join().unwrap(); - assert_eq!( as IoSelectorEventContainer>::len(&events), 1); + assert_eq!( + as IoSelectorEventContainer>::len(&events), + 1 + ); assert_eq!(events[0].id(), IoId::new(id)); assert!(events[0].is_writable()); assert!(!events[0].is_readable()); @@ -776,21 +817,35 @@ mod tests { let selector_clone = selector.clone(); // Make the pipe readable. - selector.register(read_fd, IoId::new(id), IoEventInterest::READABLE).unwrap(); + selector + .register(read_fd, IoId::new(id), IoEventInterest::READABLE) + .unwrap(); let data = 1_u8; - assert_eq!(unsafe { write(write_fd, &data as *const u8 as *const ffi::c_void, 1_usize) }, 1_isize); + assert_eq!( + unsafe { write(write_fd, &data as *const u8 as *const ffi::c_void, 1_usize) }, + 1_isize + ); // Emulate cross thread API call so waker is also woken up but since there is also other event, it will not be put into // wait state again but will process all fds assert_eq!( - unsafe { write(selector.inner.poll_waker.write_fd, &data as *const u8 as *const ffi::c_void, 1_usize) }, + unsafe { + write( + selector.inner.poll_waker.write_fd, + &data as *const u8 as *const ffi::c_void, + 1_usize, + ) + }, 1_isize ); let mut events = Vec::::new_in_global(8); assert!(selector_clone.select(&mut events, None).is_ok()); - assert_eq!( as IoSelectorEventContainer>::len(&events), 1); + assert_eq!( + as IoSelectorEventContainer>::len(&events), + 1 + ); } #[test] @@ -809,14 +864,22 @@ mod tests { begin_sync.wait(Duration::MAX); // Wait for the thread to block on poll. Obviously this isn't guaranteed to work, but I have no better idea. thread::sleep(Duration::from_secs(2)); - selector.register(read_fd, IoId::new(id), IoEventInterest::READABLE).unwrap(); + selector + .register(read_fd, IoId::new(id), IoEventInterest::READABLE) + .unwrap(); // Make the pipe readable. let data = 1_u8; - assert_eq!(unsafe { write(write_fd, &data as *const u8 as *const ffi::c_void, 1_usize) }, 1_isize); + assert_eq!( + unsafe { write(write_fd, &data as *const u8 as *const ffi::c_void, 1_usize) }, + 1_isize + ); let events = join_handle.join().unwrap(); - assert_eq!( as IoSelectorEventContainer>::len(&events), 1); + assert_eq!( + as IoSelectorEventContainer>::len(&events), + 1 + ); assert_eq!(events[0].id(), IoId::new(id)); assert!(events[0].is_readable()); assert!(!events[0].is_writable()); @@ -841,13 +904,18 @@ mod tests { begin_sync.wait(Duration::MAX); // Wait for the thread to block on poll. Obviously this isn't guaranteed to work, but I have no better idea. thread::sleep(Duration::from_secs(2)); - selector.register(write_fd, IoId::new(id), IoEventInterest::WRITABLE).unwrap(); + selector + .register(write_fd, IoId::new(id), IoEventInterest::WRITABLE) + .unwrap(); // Make the pipe writable. read_until_blocking(read_fd); let events = join_handle.join().unwrap(); - assert_eq!( as IoSelectorEventContainer>::len(&events), 1); + assert_eq!( + as IoSelectorEventContainer>::len(&events), + 1 + ); assert_eq!(events[0].id(), IoId::new(id)); assert!(events[0].is_writable()); assert!(!events[0].is_readable()); @@ -858,12 +926,17 @@ mod tests { let (read_fd, write_fd) = create_pipe(); let id = 1; let selector = Selector::new(8); - selector.register(read_fd, IoId::new(id), IoEventInterest::READABLE).unwrap(); + selector + .register(read_fd, IoId::new(id), IoEventInterest::READABLE) + .unwrap(); selector.deregister(read_fd).unwrap(); let (begin_sync, _, join_handle) = create_thread(move || { let mut events = Vec::::new_in_global(8); - assert_eq!(selector.select(&mut events, Some(Duration::from_secs(2))), Err(CommonErrors::Timeout)); + assert_eq!( + selector.select(&mut events, Some(Duration::from_secs(2))), + Err(CommonErrors::Timeout) + ); events }); @@ -871,10 +944,16 @@ mod tests { // Make the pipe readable. let data = 1_u8; - assert_eq!(unsafe { write(write_fd, &data as *const u8 as *const ffi::c_void, 1_usize) }, 1_isize); + assert_eq!( + unsafe { write(write_fd, &data as *const u8 as *const ffi::c_void, 1_usize) }, + 1_isize + ); let events = join_handle.join().unwrap(); - assert_eq!( as IoSelectorEventContainer>::len(&events), 0); + assert_eq!( + as IoSelectorEventContainer>::len(&events), + 0 + ); } #[test] @@ -882,7 +961,9 @@ mod tests { let (read_fd, write_fd) = create_pipe(); let id = 1; let selector = Selector::new(8); - selector.register(write_fd, IoId::new(id), IoEventInterest::WRITABLE).unwrap(); + selector + .register(write_fd, IoId::new(id), IoEventInterest::WRITABLE) + .unwrap(); selector.deregister(write_fd).unwrap(); // Make the pipe not writable. @@ -890,7 +971,10 @@ mod tests { let (begin_sync, _, join_handle) = create_thread(move || { let mut events = Vec::::new_in_global(8); - assert_eq!(selector.select(&mut events, Some(Duration::from_secs(2))), Err(CommonErrors::Timeout)); + assert_eq!( + selector.select(&mut events, Some(Duration::from_secs(2))), + Err(CommonErrors::Timeout) + ); events }); @@ -900,7 +984,10 @@ mod tests { read_until_blocking(read_fd); let events = join_handle.join().unwrap(); - assert_eq!( as IoSelectorEventContainer>::len(&events), 0); + assert_eq!( + as IoSelectorEventContainer>::len(&events), + 0 + ); } #[test] @@ -909,7 +996,9 @@ mod tests { let id = 1; let selector = Selector::new(8); let selector_clone = selector.clone(); - selector.register(read_fd, IoId::new(id), IoEventInterest::READABLE).unwrap(); + selector + .register(read_fd, IoId::new(id), IoEventInterest::READABLE) + .unwrap(); let (begin_sync, _, join_handle) = create_thread(move || { let mut events = Vec::::new_in_global(8); @@ -929,10 +1018,16 @@ mod tests { // Make the pipe readable. let data = 1_u8; - assert_eq!(unsafe { write(write_fd, &data as *const u8 as *const ffi::c_void, 1_usize) }, 1_isize); + assert_eq!( + unsafe { write(write_fd, &data as *const u8 as *const ffi::c_void, 1_usize) }, + 1_isize + ); let events = join_handle.join().unwrap(); - assert_eq!( as IoSelectorEventContainer>::len(&events), 0); + assert_eq!( + as IoSelectorEventContainer>::len(&events), + 0 + ); } #[test] @@ -941,7 +1036,9 @@ mod tests { let id = 1; let selector = Selector::new(8); let selector_clone = selector.clone(); - selector.register(write_fd, IoId::new(id), IoEventInterest::WRITABLE).unwrap(); + selector + .register(write_fd, IoId::new(id), IoEventInterest::WRITABLE) + .unwrap(); // Make the pipe not writable. write_until_blocking(write_fd); @@ -966,7 +1063,10 @@ mod tests { read_until_blocking(read_fd); let events = join_handle.join().unwrap(); - assert_eq!( as IoSelectorEventContainer>::len(&events), 0); + assert_eq!( + as IoSelectorEventContainer>::len(&events), + 0 + ); } #[test] @@ -977,12 +1077,17 @@ mod tests { // Make the pipe readable. let data = 1_u8; - assert_eq!(unsafe { write(write_fd, &data as *const u8 as *const ffi::c_void, 1_usize) }, 1_isize); + assert_eq!( + unsafe { write(write_fd, &data as *const u8 as *const ffi::c_void, 1_usize) }, + 1_isize + ); // Register for readable events. This select should succeed. { let selector_clone = selector.clone(); - selector_clone.register(read_fd, IoId::new(id), IoEventInterest::READABLE).unwrap(); + selector_clone + .register(read_fd, IoId::new(id), IoEventInterest::READABLE) + .unwrap(); let (_, _, join_handle) = create_thread(move || { let mut events = Vec::::new_in_global(8); @@ -991,7 +1096,10 @@ mod tests { }); let events = join_handle.join().unwrap(); - assert_eq!( as IoSelectorEventContainer>::len(&events), 1); + assert_eq!( + as IoSelectorEventContainer>::len(&events), + 1 + ); assert_eq!(events[0].id(), IoId::new(id)); assert!(events[0].is_readable()); assert!(!events[0].is_writable()); @@ -1011,13 +1119,18 @@ mod tests { }); let events = join_handle.join().unwrap(); - assert_eq!( as IoSelectorEventContainer>::len(&events), 0); + assert_eq!( + as IoSelectorEventContainer>::len(&events), + 0 + ); } // Re-register for readable events. This select should succeed. { let selector_clone = selector.clone(); - selector_clone.reregister(read_fd, IoId::new(id), IoEventInterest::READABLE).unwrap(); + selector_clone + .reregister(read_fd, IoId::new(id), IoEventInterest::READABLE) + .unwrap(); let (_, _, join_handle) = create_thread(move || { let mut events = Vec::::new_in_global(8); @@ -1026,7 +1139,10 @@ mod tests { }); let events = join_handle.join().unwrap(); - assert_eq!( as IoSelectorEventContainer>::len(&events), 1); + assert_eq!( + as IoSelectorEventContainer>::len(&events), + 1 + ); assert_eq!(events[0].id(), IoId::new(id)); assert!(events[0].is_readable()); assert!(!events[0].is_writable()); @@ -1042,7 +1158,9 @@ mod tests { // Register for writable events. This select should succeed. { let selector_clone = selector.clone(); - selector_clone.register(write_fd, IoId::new(id), IoEventInterest::WRITABLE).unwrap(); + selector_clone + .register(write_fd, IoId::new(id), IoEventInterest::WRITABLE) + .unwrap(); let (_, _, join_handle) = create_thread(move || { let mut events = Vec::::new_in_global(8); @@ -1051,7 +1169,10 @@ mod tests { }); let events = join_handle.join().unwrap(); - assert_eq!( as IoSelectorEventContainer>::len(&events), 1); + assert_eq!( + as IoSelectorEventContainer>::len(&events), + 1 + ); assert_eq!(events[0].id(), IoId::new(id)); assert!(events[0].is_writable()); assert!(!events[0].is_readable()); @@ -1071,13 +1192,18 @@ mod tests { }); let events = join_handle.join().unwrap(); - assert_eq!( as IoSelectorEventContainer>::len(&events), 0); + assert_eq!( + as IoSelectorEventContainer>::len(&events), + 0 + ); } // Re-register for writable events. This select should succeed. { let selector_clone = selector.clone(); - selector_clone.reregister(write_fd, IoId::new(id), IoEventInterest::WRITABLE).unwrap(); + selector_clone + .reregister(write_fd, IoId::new(id), IoEventInterest::WRITABLE) + .unwrap(); let (_, _, join_handle) = create_thread(move || { let mut events = Vec::::new_in_global(8); @@ -1086,7 +1212,10 @@ mod tests { }); let events = join_handle.join().unwrap(); - assert_eq!( as IoSelectorEventContainer>::len(&events), 1); + assert_eq!( + as IoSelectorEventContainer>::len(&events), + 1 + ); assert_eq!(events[0].id(), IoId::new(id)); assert!(events[0].is_writable()); assert!(!events[0].is_readable()); @@ -1098,16 +1227,24 @@ mod tests { let (read_fd, _) = create_pipe(); let id = 1; let selector = Selector::new(8); - selector.register(read_fd, IoId::new(id), IoEventInterest::READABLE).unwrap(); + selector + .register(read_fd, IoId::new(id), IoEventInterest::READABLE) + .unwrap(); let (_, _, join_handle) = create_thread(move || { let mut events = Vec::::new_in_global(8); - assert_eq!(selector.select(&mut events, Some(Duration::from_secs(2))), Err(CommonErrors::Timeout)); + assert_eq!( + selector.select(&mut events, Some(Duration::from_secs(2))), + Err(CommonErrors::Timeout) + ); events }); let events = join_handle.join().unwrap(); - assert_eq!( as IoSelectorEventContainer>::len(&events), 0); + assert_eq!( + as IoSelectorEventContainer>::len(&events), + 0 + ); } #[test] @@ -1115,18 +1252,26 @@ mod tests { let (_, write_fd) = create_pipe(); let id = 1; let selector = Selector::new(8); - selector.register(write_fd, IoId::new(id), IoEventInterest::WRITABLE).unwrap(); + selector + .register(write_fd, IoId::new(id), IoEventInterest::WRITABLE) + .unwrap(); write_until_blocking(write_fd); let (_, _, join_handle) = create_thread(move || { let mut events = Vec::::new_in_global(8); - assert_eq!(selector.select(&mut events, Some(Duration::from_secs(2))), Err(CommonErrors::Timeout)); + assert_eq!( + selector.select(&mut events, Some(Duration::from_secs(2))), + Err(CommonErrors::Timeout) + ); events }); let events = join_handle.join().unwrap(); - assert_eq!( as IoSelectorEventContainer>::len(&events), 0); + assert_eq!( + as IoSelectorEventContainer>::len(&events), + 0 + ); } #[test] @@ -1135,7 +1280,9 @@ mod tests { let id = 1; let waker_id = 2; let selector = Selector::new(8); - selector.register(read_fd, IoId::new(id), IoEventInterest::READABLE).unwrap(); + selector + .register(read_fd, IoId::new(id), IoEventInterest::READABLE) + .unwrap(); let waker = selector.create_waker(IoId::new(waker_id)).unwrap(); let (begin_sync, _, join_handle) = create_thread(move || { @@ -1151,7 +1298,10 @@ mod tests { waker.wake(); let events = join_handle.join().unwrap(); - assert_eq!( as IoSelectorEventContainer>::len(&events), 1); + assert_eq!( + as IoSelectorEventContainer>::len(&events), + 1 + ); assert_eq!(events[0].id(), IoId::new(waker_id)); } @@ -1161,7 +1311,9 @@ mod tests { let id = 1; let waker_id = 2; let selector = Selector::new(8); - selector.register(read_fd, IoId::new(id), IoEventInterest::READABLE).unwrap(); + selector + .register(read_fd, IoId::new(id), IoEventInterest::READABLE) + .unwrap(); let selector_clone = selector.clone(); let (begin_sync, _, join_handle) = create_thread(move || { @@ -1178,7 +1330,10 @@ mod tests { waker.wake(); let events = join_handle.join().unwrap(); - assert_eq!( as IoSelectorEventContainer>::len(&events), 1); + assert_eq!( + as IoSelectorEventContainer>::len(&events), + 1 + ); assert_eq!(events[0].id(), IoId::new(waker_id)); } diff --git a/src/kyron/src/mio/types.rs b/src/kyron/src/mio/types.rs index 28dc6bb..b00fbb6 100644 --- a/src/kyron/src/mio/types.rs +++ b/src/kyron/src/mio/types.rs @@ -177,7 +177,11 @@ macro_rules! impl_io_source_proxy { self.$inner.register(registry, id, interest) } - fn reregister(&mut self, id: $crate::mio::types::IoId, interest: $crate::mio::types::IoEventInterest) -> $crate::mio::types::Result<()> { + fn reregister( + &mut self, + id: $crate::mio::types::IoId, + interest: $crate::mio::types::IoEventInterest, + ) -> $crate::mio::types::Result<()> { self.$inner.reregister(id, interest) } diff --git a/src/kyron/src/net/tcp_listener.rs b/src/kyron/src/net/tcp_listener.rs index 870fb59..174f6a7 100644 --- a/src/kyron/src/net/tcp_listener.rs +++ b/src/kyron/src/net/tcp_listener.rs @@ -51,7 +51,10 @@ impl TcpListener { /// Accepts a new incoming connection to this listener. When established, the corresponding TcpStream and the remote peer’s address will be returned. pub async fn accept(&self) -> NetResult<(TcpStream, core::net::SocketAddr)> { - let res = self.listener.async_call(IoEventInterest::READABLE, |listener| listener.accept()).await?; + let res = self + .listener + .async_call(IoEventInterest::READABLE, |listener| listener.accept()) + .await?; Ok(( TcpStream { diff --git a/src/kyron/src/net/tcp_stream.rs b/src/kyron/src/net/tcp_stream.rs index 3be6d44..83f8f88 100644 --- a/src/kyron/src/net/tcp_stream.rs +++ b/src/kyron/src/net/tcp_stream.rs @@ -85,7 +85,11 @@ impl TcpStream { impl AsyncRead for TcpStream { /// # ATTENTION /// This will read data into provided `buf` only into INITIALIZED UNFILLED part of the buffer. User is responsible for growing initialized part if it uses MaybeUninit storage for `ReadBuf`! - fn poll_read(mut self: core::pin::Pin<&mut Self>, cx: &mut core::task::Context<'_>, buf: &mut ReadBuf) -> core::task::Poll> { + fn poll_read( + mut self: core::pin::Pin<&mut Self>, + cx: &mut core::task::Context<'_>, + buf: &mut ReadBuf, + ) -> core::task::Poll> { self.as_mut().stream.poll_read(cx, buf) } } diff --git a/src/kyron/src/net/udp_socket.rs b/src/kyron/src/net/udp_socket.rs index 0c78fd0..6bff3bd 100644 --- a/src/kyron/src/net/udp_socket.rs +++ b/src/kyron/src/net/udp_socket.rs @@ -87,7 +87,9 @@ impl UdpSocket { let sock_addr = resolve_as_single_address(addr).await?; self.socket - .async_call(crate::mio::types::IoEventInterest::WRITABLE, |socket| socket.send_to(buf, sock_addr)) + .async_call(crate::mio::types::IoEventInterest::WRITABLE, |socket| { + socket.send_to(buf, sock_addr) + }) .await } @@ -108,7 +110,9 @@ impl UdpSocket { /// The function must be called with valid byte array buf of sufficient size to hold the message bytes. If a message is too long to fit in the supplied buffer, excess bytes may be discarded. pub async fn recv_from(&self, buf: &mut [u8]) -> NetResult<(usize, SocketAddr)> { self.socket - .async_call(crate::mio::types::IoEventInterest::READABLE, |socket| socket.recv_from(buf)) + .async_call(crate::mio::types::IoEventInterest::READABLE, |socket| { + socket.recv_from(buf) + }) .await } diff --git a/src/kyron/src/net/utils.rs b/src/kyron/src/net/utils.rs index 31110be..2cde2d2 100644 --- a/src/kyron/src/net/utils.rs +++ b/src/kyron/src/net/utils.rs @@ -52,7 +52,7 @@ impl ToSocketAddrs for &str { Err(e) => { error!("Failed to parse socket address: {}", e); Err(std::io::Error::from(ErrorKind::Unsupported)) - } + }, } } } diff --git a/src/kyron/src/runtime/runtime_impl.rs b/src/kyron/src/runtime/runtime_impl.rs index eaf87ad..d166b47 100644 --- a/src/kyron/src/runtime/runtime_impl.rs +++ b/src/kyron/src/runtime/runtime_impl.rs @@ -68,7 +68,9 @@ impl RuntimeBuilder { } engines.reverse(); - Ok(Runtime { engines: engines.into() }) + Ok(Runtime { + engines: engines.into(), + }) } } @@ -95,11 +97,19 @@ impl Runtime { /// Runs the given future to completion on the specified engine, blocking the current thread. /// /// Returns the result of the future or an error if the engine is not available. - pub fn block_on_engine(&mut self, engine_id: usize, future: T) -> Result + pub fn block_on_engine( + &mut self, + engine_id: usize, + future: T, + ) -> Result where T::Output: Send, { - Ok(self.engines.get_mut(engine_id).ok_or(RuntimeErrors::EngineNotAvailable)?.block_on(future)) + Ok(self + .engines + .get_mut(engine_id) + .ok_or(RuntimeErrors::EngineNotAvailable)? + .block_on(future)) } /// Starts the given future asynchronously on the default engine. @@ -115,7 +125,11 @@ impl Runtime { /// Starts the given future asynchronously on the specified engine. /// /// Returns [`JoinHandle`] that can be used to retrieve result or an error - pub fn spawn_in_engine(&mut self, engine_id: usize, future: T) -> Result, RuntimeErrors> + pub fn spawn_in_engine( + &mut self, + engine_id: usize, + future: T, + ) -> Result, RuntimeErrors> where T::Output: Send, { @@ -168,7 +182,8 @@ mod tests { let drop_counter1_clone = drop_counter1.clone(); let threads_while: usize = { - let (builder, engine_id) = RuntimeBuilder::new().with_engine(ExecutionEngineBuilder::new().task_queue_size(8).workers(3)); + let (builder, engine_id) = + RuntimeBuilder::new().with_engine(ExecutionEngineBuilder::new().task_queue_size(8).workers(3)); let mut runtime = builder.build().unwrap(); let t: Result, RuntimeErrors> = runtime.block_on_engine(engine_id, async move { drop_counter1_clone.fetch_add(1, Ordering::SeqCst); @@ -197,13 +212,15 @@ mod tests { // for an example CI run. #[cfg(not(miri))] fn test_kyron_return_value() { - let (builder, engine_id) = RuntimeBuilder::new().with_engine(ExecutionEngineBuilder::new().task_queue_size(8).workers(3)); + let (builder, engine_id) = + RuntimeBuilder::new().with_engine(ExecutionEngineBuilder::new().task_queue_size(8).workers(3)); let mut runtime = builder.build().unwrap(); let ret: Result = runtime.block_on_engine(engine_id, async move { Ok(23) }).unwrap(); assert_eq!(ret, Ok(23)); - let (builder, engine_id) = RuntimeBuilder::new().with_engine(ExecutionEngineBuilder::new().task_queue_size(8).workers(3)); + let (builder, engine_id) = + RuntimeBuilder::new().with_engine(ExecutionEngineBuilder::new().task_queue_size(8).workers(3)); let mut runtime = builder.build().unwrap(); let ret: Result = runtime.block_on_engine(engine_id, async move { Ok(42) }).unwrap(); @@ -219,7 +236,8 @@ mod tests { // for an example CI run. #[cfg(not(miri))] fn test_kyron_async_run_and_late_wait() { - let (builder, engine_id) = RuntimeBuilder::new().with_engine(ExecutionEngineBuilder::new().task_queue_size(8).workers(2)); + let (builder, engine_id) = + RuntimeBuilder::new().with_engine(ExecutionEngineBuilder::new().task_queue_size(8).workers(2)); let mut runtime = builder.build().unwrap(); let barrier = Arc::new(ThreadWaitBarrier::new(1)); @@ -248,7 +266,8 @@ mod tests { // for an example CI run. #[cfg(not(miri))] fn test_kyron_wait_for_all_engines() { - let (builder, engine_id1) = RuntimeBuilder::new().with_engine(ExecutionEngineBuilder::new().task_queue_size(8).workers(2)); + let (builder, engine_id1) = + RuntimeBuilder::new().with_engine(ExecutionEngineBuilder::new().task_queue_size(8).workers(2)); let (builder, engine_id2) = builder.with_engine(ExecutionEngineBuilder::new().task_queue_size(8).workers(2)); let mut runtime = builder.build().unwrap(); diff --git a/src/kyron/src/safety.rs b/src/kyron/src/safety.rs index 88fa440..0e5ae37 100644 --- a/src/kyron/src/safety.rs +++ b/src/kyron/src/safety.rs @@ -133,7 +133,10 @@ where /// This API is intended to provide a way to ensure that user can react on errors within a `task` independent of other workers state (ie. being busy looping etc). /// This means that if the `task` (aka provided Future) will return Err(_), then the task that is awaiting on JoinHandle will be woken up in `SafetyWorker`. /// -pub fn spawn_from_boxed_on_dedicated(boxed: FutureBox>, worker_id: UniqueWorkerId) -> JoinHandle> +pub fn spawn_from_boxed_on_dedicated( + boxed: FutureBox>, + worker_id: UniqueWorkerId, +) -> JoinHandle> where T: Send + 'static, E: Send + 'static, diff --git a/src/kyron/src/scheduler/context.rs b/src/kyron/src/scheduler/context.rs index c664243..123ddcf 100644 --- a/src/kyron/src/scheduler/context.rs +++ b/src/kyron/src/scheduler/context.rs @@ -81,17 +81,25 @@ impl Handler { where T: Send + 'static, { - self.reusable_safety_internal(reusable, |reusable, id, scheduler| Arc::new(AsyncTask::new(reusable, id, scheduler))) + self.reusable_safety_internal(reusable, |reusable, id, scheduler| { + Arc::new(AsyncTask::new(reusable, id, scheduler)) + }) } pub(crate) fn spawn_on_dedicated(&self, boxed: FutureBox, worker_id: UniqueWorkerId) -> JoinHandle where T: Send + 'static, { - self.on_dedicated_internal(boxed, worker_id, |f, id, scheduler| Arc::new(AsyncTask::new(f, id, scheduler))) + self.on_dedicated_internal(boxed, worker_id, |f, id, scheduler| { + Arc::new(AsyncTask::new(f, id, scheduler)) + }) } - pub(crate) fn spawn_reusable_on_dedicated(&self, reusable: ReusableBoxFuture, worker_id: UniqueWorkerId) -> JoinHandle + pub(crate) fn spawn_reusable_on_dedicated( + &self, + reusable: ReusableBoxFuture, + worker_id: UniqueWorkerId, + ) -> JoinHandle where T: Send + 'static, { @@ -110,7 +118,10 @@ impl Handler { }) } - pub(crate) fn spawn_reusable_safety(&self, reusable: ReusableBoxFuture>) -> JoinHandle> + pub(crate) fn spawn_reusable_safety( + &self, + reusable: ReusableBoxFuture>, + ) -> JoinHandle> where T: Send + 'static, E: Send + 'static, @@ -155,17 +166,21 @@ impl Handler { match self.inner { HandlerImpl::Async(ref async_inner) => { a(Some(&async_inner.prod_con)); - } + }, HandlerImpl::Dedicated(_) => { a(None); - } + }, } } fn internal( &self, boxed: FutureBox, - c: impl Fn(FutureBox, &WorkerId, Arc) -> Arc + Send>, Arc>>, + c: impl Fn( + FutureBox, + &WorkerId, + Arc, + ) -> Arc + Send>, Arc>>, ) -> JoinHandle where T: Send + 'static, @@ -181,15 +196,17 @@ impl Handler { task_ref = TaskRef::new(task.clone()); handle = JoinHandle::new(task_ref.clone()); - async_inner.scheduler.spawn_from_runtime(task_ref, &async_inner.prod_con); - } + async_inner + .scheduler + .spawn_from_runtime(task_ref, &async_inner.prod_con); + }, HandlerImpl::Dedicated(ref dedicated_inner) => { let task = c(boxed, &worker_id, dedicated_inner.scheduler.clone()); task_ref = TaskRef::new(task.clone()); handle = JoinHandle::new(task_ref.clone()); dedicated_inner.scheduler.spawn_outside_runtime(task_ref); - } + }, } handle @@ -198,7 +215,11 @@ impl Handler { fn reusable_safety_internal( &self, reusable: ReusableBoxFuture, - c: impl Fn(Pin>, &WorkerId, Arc) -> Arc, Arc>>, + c: impl Fn( + Pin>, + &WorkerId, + Arc, + ) -> Arc, Arc>>, ) -> JoinHandle where T: Send + 'static, @@ -214,15 +235,17 @@ impl Handler { task_ref = TaskRef::new(task.clone()); handle = JoinHandle::new(task_ref.clone()); - async_inner.scheduler.spawn_from_runtime(task_ref, &async_inner.prod_con); - } + async_inner + .scheduler + .spawn_from_runtime(task_ref, &async_inner.prod_con); + }, HandlerImpl::Dedicated(ref dedicated_inner) => { let task = c(reusable.into_pin(), &worker_id, dedicated_inner.scheduler.clone()); task_ref = TaskRef::new(task.clone()); handle = JoinHandle::new(task_ref.clone()); dedicated_inner.scheduler.spawn_outside_runtime(task_ref); - } + }, } handle @@ -246,7 +269,11 @@ impl Handler { HandlerImpl::Dedicated(ref dedicated_inner) => &dedicated_inner.dedicated_scheduler, }; - let task = c(boxed, &ctx_get_worker_id(), DedicatedSchedulerLocal::new(worker_id, scheduler.clone())); + let task = c( + boxed, + &ctx_get_worker_id(), + DedicatedSchedulerLocal::new(worker_id, scheduler.clone()), + ); let task_ref = TaskRef::new(task.clone()); let handle = JoinHandle::new(task_ref.clone()); @@ -261,7 +288,11 @@ impl Handler { &self, reusable: ReusableBoxFuture, worker_id: UniqueWorkerId, - c: impl Fn(Pin>, &WorkerId, DedicatedSchedulerLocal) -> Arc, DedicatedSchedulerLocal>>, + c: impl Fn( + Pin>, + &WorkerId, + DedicatedSchedulerLocal, + ) -> Arc, DedicatedSchedulerLocal>>, ) -> JoinHandle where T: Send + 'static, @@ -291,10 +322,10 @@ impl Handler { match self.inner { HandlerImpl::Async(_) => { not_recoverable_error!("Unpark called on async handler, this is not allowed! This should be called only on dedicated handlers!"); - } + }, HandlerImpl::Dedicated(ref sched) => { sched.scheduler.try_notify_siblings_workers(None); - } + }, } } } @@ -378,7 +409,11 @@ impl ContextBuilder { self } - pub(super) fn with_dedicated_handle(mut self, s: Arc, dedicated_scheduler: Arc) -> Self { + pub(super) fn with_dedicated_handle( + mut self, + s: Arc, + dedicated_scheduler: Arc, + ) -> Self { assert!(self.handle.is_none(), "Cannot set two handlers for single context"); let handle = Handler { @@ -396,7 +431,9 @@ impl ContextBuilder { WorkerContext { running_task: RefCell::new(None), worker_id: Cell::new(self.worker_id.expect("Worker type must be set in context builder!")), - handler: RefCell::new(Some(Rc::new(self.handle.expect("Handler type must be set in context builder!")))), + handler: RefCell::new(Some(Rc::new( + self.handle.expect("Handler type must be set in context builder!"), + ))), is_safety_enabled: self.is_with_safety, wakeup_time: Cell::new(None), drivers: Some(self.drivers), @@ -447,13 +484,24 @@ pub(crate) fn ctx_get_worker_id() -> WorkerId { /// Check if safety was enabled /// pub(crate) fn ctx_is_with_safety() -> bool { - CTX.try_with(|ctx| ctx.borrow().as_ref().expect("Called before CTX init?").is_safety_enabled) - .unwrap_or_default() + CTX.try_with(|ctx| { + ctx.borrow() + .as_ref() + .expect("Called before CTX init?") + .is_safety_enabled + }) + .unwrap_or_default() } pub(crate) fn ctx_set_wakeup_time(time: u64) { - CTX.try_with(|ctx| ctx.borrow().as_ref().expect("Called before CTX init?").wakeup_time.set(Some(time))) - .unwrap_or_default(); + CTX.try_with(|ctx| { + ctx.borrow() + .as_ref() + .expect("Called before CTX init?") + .wakeup_time + .set(Some(time)) + }) + .unwrap_or_default(); } /// @@ -472,13 +520,26 @@ pub(crate) fn ctx_get_wakeup_time() -> u64 { } pub(crate) fn ctx_unset_wakeup_time() { - CTX.try_with(|ctx| ctx.borrow().as_ref().expect("Called before CTX init?").wakeup_time.take()) - .unwrap_or_default(); + CTX.try_with(|ctx| { + ctx.borrow() + .as_ref() + .expect("Called before CTX init?") + .wakeup_time + .take() + }) + .unwrap_or_default(); } pub(crate) fn ctx_get_drivers() -> Drivers { - CTX.try_with(|ctx| ctx.borrow().as_ref().expect("Called before CTX init?").drivers.clone().unwrap()) - .unwrap() + CTX.try_with(|ctx| { + ctx.borrow() + .as_ref() + .expect("Called before CTX init?") + .drivers + .clone() + .unwrap() + }) + .unwrap() } /// @@ -487,7 +548,11 @@ pub(crate) fn ctx_get_drivers() -> Drivers { pub(super) fn ctx_set_running_task(task: TaskRef) { let _ = CTX .try_with(|ctx| { - ctx.borrow().as_ref().expect("Called before CTX init?").running_task.replace(Some(task)); + ctx.borrow() + .as_ref() + .expect("Called before CTX init?") + .running_task + .replace(Some(task)); }) .map_err(|e| { panic!("Something is really bad here, error {}!", e); @@ -500,7 +565,11 @@ pub(super) fn ctx_set_running_task(task: TaskRef) { pub(super) fn ctx_unset_running_task() { let _ = CTX .try_with(|ctx| { - ctx.borrow().as_ref().expect("Called before CTX init?").running_task.replace(None); + ctx.borrow() + .as_ref() + .expect("Called before CTX init?") + .running_task + .replace(None); }) .map_err(|_| {}); } diff --git a/src/kyron/src/scheduler/driver.rs b/src/kyron/src/scheduler/driver.rs index c88224a..0c51077 100644 --- a/src/kyron/src/scheduler/driver.rs +++ b/src/kyron/src/scheduler/driver.rs @@ -24,7 +24,9 @@ use crate::io::driver::IoDriver; use crate::io::AsyncSelector; use crate::{ scheduler::{ - context::{ctx_get_handler, ctx_get_wakeup_time, ctx_get_worker_id, ctx_set_wakeup_time, ctx_unset_wakeup_time}, + context::{ + ctx_get_handler, ctx_get_wakeup_time, ctx_get_worker_id, ctx_set_wakeup_time, ctx_unset_wakeup_time, + }, scheduler_mt::AsyncScheduler, workers::worker_types::{WorkerInteractor, *}, }, @@ -130,13 +132,20 @@ impl Inner { self.park_with_timeout(scheduler, worker, &expire_time_instant, expire_time_u64); } - fn park_with_timeout(&self, scheduler: &AsyncScheduler, worker: &WorkerInteractor, expire_time_instant: &Instant, expire_time_u64: u64) { + fn park_with_timeout( + &self, + scheduler: &AsyncScheduler, + worker: &WorkerInteractor, + expire_time_instant: &Instant, + expire_time_u64: u64, + ) { let res = worker.park( scheduler, &self.io, || { // We sleep to new timeout - self.next_promised_wakeup.store(expire_time_u64, ::core::sync::atomic::Ordering::Relaxed); + self.next_promised_wakeup + .store(expire_time_u64, ::core::sync::atomic::Ordering::Relaxed); self.stash_promised_wakeup_time_for_worker(expire_time_u64); }, Some(self.time.duration_since_now(expire_time_instant)), diff --git a/src/kyron/src/scheduler/execution_engine.rs b/src/kyron/src/scheduler/execution_engine.rs index dd29eb9..c55275d 100644 --- a/src/kyron/src/scheduler/execution_engine.rs +++ b/src/kyron/src/scheduler/execution_engine.rs @@ -120,7 +120,12 @@ impl ExecutionEngine { }); let scheduler = self.get_async_scheduler(); - let worker_id = WorkerId::new("MainThread".into(), MAIN_THREAD_ID, MAIN_THREAD_ID, WorkerType::Dedicated); + let worker_id = WorkerId::new( + "MainThread".into(), + MAIN_THREAD_ID, + MAIN_THREAD_ID, + WorkerType::Dedicated, + ); let task = Arc::new(AsyncTask::new(boxed, &worker_id, scheduler)); let entry_task = TaskRef::new(task.clone()); @@ -205,10 +210,10 @@ impl ExecutionEngine { match res { Ok(_) => { debug!("Workers ready, continue..."); - } + }, Err(_) => { panic!("Timeout on starting engine, not all workers reported ready, stopping..."); - } + }, } } } @@ -276,7 +281,11 @@ impl ExecutionEngineBuilder { /// >ATTENTION: `size` has to be power of two /// pub fn task_queue_size(mut self, size: u32) -> Self { - assert!(size.is_power_of_two(), "Task queue size ({}) must be power of two", size); + assert!( + size.is_power_of_two(), + "Task queue size ({}) must be power of two", + size + ); self.queue_size = size; self } @@ -326,8 +335,15 @@ impl ExecutionEngineBuilder { /// >ATTENTION: `size` has to be power of two and safety worker shall be enabled prior to queue size configuration. /// pub fn safety_worker_task_queue_size(mut self, size: u32) -> Self { - assert!(size.is_power_of_two(), "Safety worker task queue size ({}) must be power of two", size); - assert!(self.with_safe_worker.0, "Enable safety worker prior to configuring its queue size."); + assert!( + size.is_power_of_two(), + "Safety worker task queue size ({}) must be power of two", + size + ); + assert!( + self.with_safe_worker.0, + "Enable safety worker prior to configuring its queue size." + ); self.safety_worker_queue_size = size; self } @@ -370,7 +386,12 @@ impl ExecutionEngineBuilder { // so lets assign safety worker id after all the workers let safety_worker_id = self.async_workers_cnt + self.dedicated_workers_ids.len(); let w = SafetyWorker::new( - WorkerId::new("SafetyWorker".into(), self.id, safety_worker_id as u8, WorkerType::Dedicated), + WorkerId::new( + "SafetyWorker".into(), + self.id, + safety_worker_id as u8, + WorkerType::Dedicated, + ), self.with_safe_worker.1, self.safety_worker_queue_size, ); @@ -393,7 +414,12 @@ impl ExecutionEngineBuilder { .push(create_steal_queue(self.queue_size)) .expect("Failed to add new steal queue for async worker"); - let id = WorkerId::new(format!("arunner{}", i).as_str().into(), self.id, i as u8, WorkerType::Async); + let id = WorkerId::new( + format!("arunner{}", i).as_str().into(), + self.id, + i as u8, + WorkerType::Async, + ); worker_interactors[i].write(WorkerInteractor::new(async_queues[i].clone(), id)); @@ -414,11 +440,17 @@ impl ExecutionEngineBuilder { // Create dedicated workers part let mut dedicated_workers = Vec::new_in_global(core::cmp::max(self.dedicated_workers_ids.len(), 1)); - let mut dedicated_queues = Box::<[(WorkerId, Arc>)]>::new_uninit_slice(self.dedicated_workers_ids.len()); + let mut dedicated_queues = + Box::<[(WorkerId, Arc>)]>::new_uninit_slice(self.dedicated_workers_ids.len()); let dedicated_worker_id_start = self.async_workers_cnt; for i in 0..self.dedicated_workers_ids.len() { let id = self.dedicated_workers_ids[i].0; - let real_id = WorkerId::new(id, self.id, (dedicated_worker_id_start + i) as u8, WorkerType::Dedicated); + let real_id = WorkerId::new( + id, + self.id, + (dedicated_worker_id_start + i) as u8, + WorkerType::Dedicated, + ); let thread_params = self.dedicated_workers_ids[i].1.clone(); dedicated_workers .push(DedicatedWorker::new(real_id, self.with_safe_worker.0, thread_params)) @@ -473,7 +505,10 @@ mod tests { #[allow(dead_code)] fn create_engine(workers: usize) -> ExecutionEngine { - ExecutionEngineBuilder::new().workers(workers).task_queue_size(8).build() + ExecutionEngineBuilder::new() + .workers(workers) + .task_queue_size(8) + .build() } #[test] @@ -507,7 +542,11 @@ mod tests { #[cfg(not(miri))] // Provenance issues fn create_engine_with_worker_and_verify_ids() { use crate::scheduler::context::{ctx_get_running_task_id, ctx_get_worker_id}; - let mut engine = ExecutionEngineBuilder::new().workers(1).task_queue_size(16).set_engine_id(1).build(); + let mut engine = ExecutionEngineBuilder::new() + .workers(1) + .task_queue_size(16) + .set_engine_id(1) + .build(); let result: Result = engine .run_in_engine(async move { let engine_id = ctx_get_worker_id().engine_id(); @@ -515,7 +554,10 @@ mod tests { let task_id = ctx_get_running_task_id().unwrap(); let task_created_by_worker = task_id.worker(); let task_created_by_engine = task_id.engine(); - Ok(engine_id == 1 && worker_id == 0 && task_created_by_worker == MAIN_THREAD_ID && task_created_by_engine == MAIN_THREAD_ID) + Ok(engine_id == 1 + && worker_id == 0 + && task_created_by_worker == MAIN_THREAD_ID + && task_created_by_engine == MAIN_THREAD_ID) }) .join(); @@ -528,7 +570,8 @@ mod tests { fn test_more_than_max_dedicated_worker_cannot_be_created() { let mut builder = ExecutionEngineBuilder::new(); for i in 0..(MAX_NUM_OF_DEDICATED_WORKERS + 1) { - builder = builder.with_dedicated_worker(("id".to_string() + &i.to_string()).into(), ThreadParameters::default()); + builder = + builder.with_dedicated_worker(("id".to_string() + &i.to_string()).into(), ThreadParameters::default()); } } diff --git a/src/kyron/src/scheduler/join_handle.rs b/src/kyron/src/scheduler/join_handle.rs index 69f5a36..889f489 100644 --- a/src/kyron/src/scheduler/join_handle.rs +++ b/src/kyron/src/scheduler/join_handle.rs @@ -80,13 +80,15 @@ impl Future for JoinHandle { match ret { Ok(v) => FutureInternalReturn::ready(Ok(v)), - Err(CommonErrors::OperationAborted) => FutureInternalReturn::ready(Err(CommonErrors::OperationAborted)), + Err(CommonErrors::OperationAborted) => { + FutureInternalReturn::ready(Err(CommonErrors::OperationAborted)) + }, Err(e) => { not_recoverable_error!(with e, "There has been an error in a task that is not recoverable ({})!"); - } + }, } } - } + }, FutureState::Polled => { // Safety belows forms AqrRel so waker is really written before we do marking let mut ret: Result = Err(CommonErrors::NoData); @@ -96,15 +98,17 @@ impl Future for JoinHandle { match ret { Ok(v) => FutureInternalReturn::ready(Ok(v)), Err(CommonErrors::NoData) => FutureInternalReturn::polled(), - Err(CommonErrors::OperationAborted) => FutureInternalReturn::ready(Err(CommonErrors::OperationAborted)), + Err(CommonErrors::OperationAborted) => { + FutureInternalReturn::ready(Err(CommonErrors::OperationAborted)) + }, Err(e) => { not_recoverable_error!(with e, "There has been an error in a task that is not recoverable ({})!"); - } + }, } - } + }, FutureState::Finished => { not_recoverable_error!("Future polled after it finished!"); - } + }, }; self.get_mut().state.assign_and_propagate(res) @@ -136,7 +140,11 @@ mod tests { { // Data is present after first poll of join handle let worker_id = create_mock_worker_id(0, 1); - let task = ArcInternal::new(AsyncTask::new(box_future(test_function::()), &worker_id, scheduler.clone())); + let task = ArcInternal::new(AsyncTask::new( + box_future(test_function::()), + &worker_id, + scheduler.clone(), + )); let handle = JoinHandle::::new(TaskRef::new(task.clone())); @@ -159,7 +167,11 @@ mod tests { { // Data is present before first poll of join handle let worker_id = create_mock_worker_id(0, 1); - let task = ArcInternal::new(AsyncTask::new(box_future(test_function_ret::(1234)), &worker_id, scheduler.clone())); + let task = ArcInternal::new(AsyncTask::new( + box_future(test_function_ret::(1234)), + &worker_id, + scheduler.clone(), + )); let handle = JoinHandle::::new(TaskRef::new(task.clone())); @@ -182,7 +194,11 @@ mod tests { { let worker_id = create_mock_worker_id(0, 1); - let task = ArcInternal::new(AsyncTask::new(box_future(test_function_ret::(1234)), &worker_id, scheduler.clone())); + let task = ArcInternal::new(AsyncTask::new( + box_future(test_function_ret::(1234)), + &worker_id, + scheduler.clone(), + )); let handle = JoinHandle::::new(TaskRef::new(task.clone())); @@ -199,12 +215,19 @@ mod tests { { let worker_id = create_mock_worker_id(0, 1); - let task = ArcInternal::new(AsyncTask::new(box_future(test_function::()), &worker_id, scheduler.clone())); + let task = ArcInternal::new(AsyncTask::new( + box_future(test_function::()), + &worker_id, + scheduler.clone(), + )); let handle = JoinHandle::::new(TaskRef::new(task.clone())); let mut poller = TestingFuturePoller::new(handle); assert!(task.abort()); - assert_eq!(poller.poll(), ::core::task::Poll::Ready(Err(CommonErrors::OperationAborted))); + assert_eq!( + poller.poll(), + ::core::task::Poll::Ready(Err(CommonErrors::OperationAborted)) + ); } } @@ -216,7 +239,11 @@ mod tests { { // Data is present before first poll of join handle let worker_id = create_mock_worker_id(0, 1); - let task = ArcInternal::new(AsyncTask::new(box_future(test_function::()), &worker_id, scheduler.clone())); + let task = ArcInternal::new(AsyncTask::new( + box_future(test_function::()), + &worker_id, + scheduler.clone(), + )); let handle = JoinHandle::::new(TaskRef::new(task.clone())); @@ -242,7 +269,11 @@ mod tests { { // Data is present before first poll of join handle let worker_id = create_mock_worker_id(0, 1); - let task = ArcInternal::new(AsyncTask::new(box_future(test_function::()), &worker_id, scheduler.clone())); + let task = ArcInternal::new(AsyncTask::new( + box_future(test_function::()), + &worker_id, + scheduler.clone(), + )); let handle = JoinHandle::::new(TaskRef::new(task.clone())); @@ -292,7 +323,11 @@ mod tests { { // Data is present after first poll of join handle let worker_id = create_mock_worker_id(0, 1); - let task = ArcInternal::new(AsyncTask::new(box_future(test_function_ret::(1234)), &worker_id, scheduler.clone())); + let task = ArcInternal::new(AsyncTask::new( + box_future(test_function_ret::(1234)), + &worker_id, + scheduler.clone(), + )); let handle = JoinHandle::::new(TaskRef::new(task.clone())); @@ -319,10 +354,10 @@ mod tests { } break; - } + }, Poll::Pending => { was_pending = true; - } + }, } loom::hint::spin_loop(); } @@ -342,7 +377,11 @@ mod tests { { // Data is present after first poll of join handle let worker_id = create_mock_worker_id(0, 1); - let task = ArcInternal::new(AsyncTask::new(box_future(test_function_ret::(1234)), &worker_id, scheduler.clone())); + let task = ArcInternal::new(AsyncTask::new( + box_future(test_function_ret::(1234)), + &worker_id, + scheduler.clone(), + )); let join_handle = JoinHandle::::new(TaskRef::new(task.clone())); @@ -364,8 +403,8 @@ mod tests { match poller.poll_with_waker(&waker) { Poll::Ready(v) => { break v; - } - Poll::Pending => {} + }, + Poll::Pending => {}, } loom::hint::spin_loop(); }; @@ -379,11 +418,11 @@ mod tests { Ok(v) => { assert_eq!(v, 1234); assert!(!waker_mock.was_waked()); - } + }, Err(err) => { assert_eq!(err, CommonErrors::OperationAborted); assert!(!waker_mock.was_waked()); - } + }, } } diff --git a/src/kyron/src/scheduler/scheduler_mt.rs b/src/kyron/src/scheduler/scheduler_mt.rs index 532481c..eaf50ea 100644 --- a/src/kyron/src/scheduler/scheduler_mt.rs +++ b/src/kyron/src/scheduler/scheduler_mt.rs @@ -79,11 +79,11 @@ impl AsyncScheduler { match local_queue.push(task, &self.global_queue) { Ok(_) => { self.try_notify_siblings_workers(Some(ctx_get_worker_id())); - } + }, Err(_) => { // TODO: Add error hooks so we can notify app owner that we are done panic!("Cannot push to queue anymore, overflow!"); - } + }, } } @@ -139,19 +139,23 @@ impl AsyncScheduler { /// Tries to move worker to searching state if conditions are met. No more than half of workers shall be in searching state to avoid too much contention on stealing queue /// pub(super) fn try_transition_worker_to_searching(&self) -> bool { - let searching = self.num_of_searching_workers.load(::core::sync::atomic::Ordering::SeqCst); + let searching = self + .num_of_searching_workers + .load(::core::sync::atomic::Ordering::SeqCst); let predicted = (searching * SCHEDULER_MAX_SEARCHING_WORKERS_DIVIDER) as usize; if predicted >= self.worker_access.len() { return false; } - self.num_of_searching_workers.fetch_add(1, ::core::sync::atomic::Ordering::SeqCst); + self.num_of_searching_workers + .fetch_add(1, ::core::sync::atomic::Ordering::SeqCst); true } pub(super) fn transition_worker_to_executing(&self) { - self.num_of_searching_workers.fetch_sub(1, ::core::sync::atomic::Ordering::SeqCst); + self.num_of_searching_workers + .fetch_sub(1, ::core::sync::atomic::Ordering::SeqCst); } pub(super) fn transition_to_parked(&self, was_searching: bool, id: WorkerId) -> bool { @@ -160,7 +164,9 @@ impl AsyncScheduler { let mut num_of_searching = 2; //2 as false condition if was_searching { - num_of_searching = self.num_of_searching_workers.fetch_sub(1, ::core::sync::atomic::Ordering::SeqCst); + num_of_searching = self + .num_of_searching_workers + .fetch_sub(1, ::core::sync::atomic::Ordering::SeqCst); } guard.push(id.worker_id() as usize).expect("Failed to push worker id"); // worker_id is index in worker_access @@ -220,7 +226,9 @@ impl AsyncScheduler { // A worker should be notified only if no other workers are already in the searching state. // fn should_notify_some_worker(&self) -> bool { - self.num_of_searching_workers.fetch_sub(0, ::core::sync::atomic::Ordering::SeqCst) == 0 + self.num_of_searching_workers + .fetch_sub(0, ::core::sync::atomic::Ordering::SeqCst) + == 0 } } @@ -287,7 +295,11 @@ impl SchedulerTrait for DedicatedSchedulerLocalInner { #[cfg(test)] #[allow(dead_code)] -pub(crate) fn scheduler_new(workers_cnt: usize, local_queue_size: u32, drivers: &super::driver::Drivers) -> AsyncScheduler { +pub(crate) fn scheduler_new( + workers_cnt: usize, + local_queue_size: u32, + drivers: &super::driver::Drivers, +) -> AsyncScheduler { // artificially construct a scheduler let mut worker_interactors = BoxInternal::<[WorkerInteractor]>::new_uninit_slice(workers_cnt); diff --git a/src/kyron/src/scheduler/task/async_task.rs b/src/kyron/src/scheduler/task/async_task.rs index f7a835b..83863a9 100644 --- a/src/kyron/src/scheduler/task/async_task.rs +++ b/src/kyron/src/scheduler/task/async_task.rs @@ -170,11 +170,18 @@ where } unsafe fn poll_safety_vtable(this: NonNull, ctx: &mut Context) -> TaskPollResult { - let instance = this.as_ptr().cast::, AllocatedFuture, SchedulerType>>(); + let instance = this + .as_ptr() + .cast::, AllocatedFuture, SchedulerType>>(); unsafe { (*instance).poll_safety(ctx) } } - pub(crate) fn new_safety(is_with_safety: bool, future: Pin, worker_id: &WorkerId, scheduler: SchedulerType) -> Self { + pub(crate) fn new_safety( + is_with_safety: bool, + future: Pin, + worker_id: &WorkerId, + scheduler: SchedulerType, + ) -> Self { Self { header: TaskHeader::new_safety::(worker_id), stage: UnsafeCell::new(TaskStage::InProgress(future)), @@ -229,7 +236,7 @@ where // Since the abort cannot happen while awaiting on Task (we don't have AbortHandle as of now with would allow remote abort), we don't have any racing on stage due to `get_future_ret` self.clear_stage(); true - } + }, TransitionToCanceled::AlreadyDone => false, // We don't know whether first caller finished with Done or DoneWhileRunning TransitionToCanceled::DoneWhileRunning => false, } @@ -244,15 +251,15 @@ where TransitionToRunning::Done => { // means we are the only one who could be now running this future self.poll_core(cx, safety_checker) - } + }, TransitionToRunning::Aborted => { // if we were aborted before, it means someone else cleared up everything and we are simply done here TaskPollResult::Done - } + }, TransitionToRunning::AlreadyRunning => { // This can happen if are waken into safety but were scheduled also into normal run (ie task with 3 spawns, where one finished and other timed out) TaskPollResult::Done - } + }, } } @@ -303,26 +310,29 @@ where // Finish when future was done, but not under opened writable cell that can cause bugs if someone reorder some instructions, here we are sure let status = self.header.state.transition_to_completed(); match status { - TransitionToCompleted::Done => {} + TransitionToCompleted::Done => {}, TransitionToCompleted::HadConnectedJoinHandle => { - self.handle_waker.with_mut(|ptr: *mut Option| match unsafe { (*ptr).take() } { - Some(v) => { - if is_safety_err && self.is_with_safety { - unsafe { - create_safety_waker(v).wake(); + self.handle_waker + .with_mut(|ptr: *mut Option| match unsafe { (*ptr).take() } { + Some(v) => { + if is_safety_err && self.is_with_safety { + unsafe { + create_safety_waker(v).wake(); + } + } else { + v.wake(); } - } else { - v.wake(); - } - } - None => not_recoverable_error!("We shall never be here if we have HadConnectedJoinHandle set!"), - }) - } + }, + None => { + not_recoverable_error!("We shall never be here if we have HadConnectedJoinHandle set!") + }, + }) + }, TransitionToCompleted::Aborted => { // We are done, we can simply clear the stage and we don't need to notify via handle_waker as of now as no remote abort supported // We also do not guarantee ordering on this, but state is correct so no one except us will access stage self.clear_stage(); - } + }, } TaskPollResult::Done @@ -377,13 +387,13 @@ where TransitionToNotified::Done => { // We need to reschedule on our own self.scheduler.respawn(task); - } + }, TransitionToNotified::AlreadyNotified => { // Do nothing as someone already did it - } + }, TransitionToNotified::Running => { // Do nothing was we will be rescheduled by poll itself, still notification was marked - } + }, } } @@ -392,13 +402,13 @@ where TransitionToSafetyNotified::Done => { // We need to reschedule on our own self.scheduler.respawn_into_safety(task); - } + }, TransitionToSafetyNotified::AlreadyNotified => { // Do nothing as someone already did i t - } + }, TransitionToSafetyNotified::Running => { // Do nothing was we will be rescheduled by poll itself, still notification was marked - } + }, } } @@ -794,7 +804,12 @@ mod tests { let sched = create_mock_scheduler(); let worker_id = create_mock_worker_id(0, 1); let safety_task_parent = ArcInternal::new(AsyncTask::new(box_future(dummy()), &worker_id, sched.clone())); - let safety_task = ArcInternal::new(AsyncTask::new_safety(true, box_future(dummy_safety_ret(true)), &worker_id, sched.clone())); + let safety_task = ArcInternal::new(AsyncTask::new_safety( + true, + box_future(dummy_safety_ret(true)), + &worker_id, + sched.clone(), + )); let safety_task_ref = TaskRef::new(safety_task.clone()); let waker = get_waker_from_task(&safety_task_parent); @@ -1012,12 +1027,12 @@ mod tests { TaskPollResult::Done => { let val = scheduler.spawn_count(); assert!(val == 1 || val == 2); // Either the schedule happen before pool or after. Loom will explore all interleaving - } + }, TaskPollResult::Notified => { let val = scheduler.spawn_count(); assert!(val == 0 || val == 1); // 0 - one threads calls when we are in running, 1 - one threads call before we running - } + }, } }); } diff --git a/src/kyron/src/scheduler/task/task_state.rs b/src/kyron/src/scheduler/task/task_state.rs index 522d677..053a523 100644 --- a/src/kyron/src/scheduler/task/task_state.rs +++ b/src/kyron/src/scheduler/task/task_state.rs @@ -331,21 +331,27 @@ impl TaskState { /// /// Apply value from action and returns value from action /// - fn fetch_update_with_return (Option, U), U>(&self, mut f: T) -> U { + fn fetch_update_with_return (Option, U), U>( + &self, + mut f: T, + ) -> U { let mut val = self.s.load(::core::sync::atomic::Ordering::Acquire); loop { let (state, ret) = f(TaskStateSnapshot(val)); match state { Some(s) => { - let res = self - .s - .compare_exchange(val, s.0, ::core::sync::atomic::Ordering::AcqRel, ::core::sync::atomic::Ordering::Acquire); + let res = self.s.compare_exchange( + val, + s.0, + ::core::sync::atomic::Ordering::AcqRel, + ::core::sync::atomic::Ordering::Acquire, + ); match res { Ok(_) => break ret, Err(actual) => val = actual, } - } + }, None => break ret, } } diff --git a/src/kyron/src/scheduler/waker.rs b/src/kyron/src/scheduler/waker.rs index d357eed..ffbd025 100644 --- a/src/kyron/src/scheduler/waker.rs +++ b/src/kyron/src/scheduler/waker.rs @@ -168,11 +168,11 @@ mod tests { Some(waker) => { // If we had prev, then it shall be from current store assert_eq!(waker.data(), w.data()); - } + }, None => { // The value must have been either here or there assert!(store.take().is_some() ^ waker_from_thread.is_some()); - } + }, }; }); } diff --git a/src/kyron/src/scheduler/workers/dedicated_worker.rs b/src/kyron/src/scheduler/workers/dedicated_worker.rs index 5b75361..c17cf0f 100644 --- a/src/kyron/src/scheduler/workers/dedicated_worker.rs +++ b/src/kyron/src/scheduler/workers/dedicated_worker.rs @@ -164,14 +164,19 @@ impl WorkerInner { continue; } - match self.consumer.pop_blocking_with_timeout(::core::time::Duration::from_millis(100)) { + match self + .consumer + .pop_blocking_with_timeout(::core::time::Duration::from_millis(100)) + { Ok(task_ref) => { - self.local_storage.push(task_ref).expect("Failed to push task into local storage"); + self.local_storage + .push(task_ref) + .expect("Failed to push task into local storage"); // Storage is empty - } + }, Err(CommonErrors::Timeout) => { continue; - } + }, Err(_) => todo!(), } } @@ -185,11 +190,11 @@ impl WorkerInner { match task.poll(&mut ctx) { TaskPollResult::Done => { // Literally nothing to do ;) - } + }, TaskPollResult::Notified => { // For now stupid respawn self.dedicated_scheduler.spawn(task, self.id.unique_id()); - } + }, } } } diff --git a/src/kyron/src/scheduler/workers/mod.rs b/src/kyron/src/scheduler/workers/mod.rs index f7a4a2d..33a9826 100644 --- a/src/kyron/src/scheduler/workers/mod.rs +++ b/src/kyron/src/scheduler/workers/mod.rs @@ -58,7 +58,12 @@ impl ThreadParameters { } } -pub(crate) fn spawn_thread(tname: &'static str, id: &WorkerId, f: F, thread_params: &ThreadParameters) -> Result +pub(crate) fn spawn_thread( + tname: &'static str, + id: &WorkerId, + f: F, + thread_params: &ThreadParameters, +) -> Result where T: Debug + Send + 'static, F: FnOnce() -> T + Send + 'static, diff --git a/src/kyron/src/scheduler/workers/safety_worker.rs b/src/kyron/src/scheduler/workers/safety_worker.rs index 86369ee..27b8ef5 100644 --- a/src/kyron/src/scheduler/workers/safety_worker.rs +++ b/src/kyron/src/scheduler/workers/safety_worker.rs @@ -16,7 +16,8 @@ use std::sync::Arc; use iceoryx2_bb_posix::thread::Thread; use kyron_foundation::{ - containers::trigger_queue::TriggerQueue, prelude::vector_extension::VectorExtension, threading::thread_wait_barrier::ThreadReadyNotifier, + containers::trigger_queue::TriggerQueue, prelude::vector_extension::VectorExtension, + threading::thread_wait_barrier::ThreadReadyNotifier, }; use crate::{ @@ -124,7 +125,12 @@ struct WorkerInner { } impl WorkerInner { - fn pre_run(&mut self, drivers: Drivers, dedicated_scheduler: Arc, scheduler: Arc) { + fn pre_run( + &mut self, + drivers: Drivers, + dedicated_scheduler: Arc, + scheduler: Arc, + ) { let builder = ContextBuilder::new(drivers) .thread_id(0) .with_dedicated_handle(scheduler, dedicated_scheduler) @@ -157,11 +163,13 @@ impl WorkerInner { match consumer.pop_blocking_with_timeout(::core::time::Duration::from_millis(100)) { Ok(task_ref) => { // Storage is empty - self.local_storage.push(task_ref).expect("Failed to push task into local storage"); - } + self.local_storage + .push(task_ref) + .expect("Failed to push task into local storage"); + }, Err(CommonErrors::Timeout) => { continue; - } + }, Err(_) => todo!(), } } @@ -174,11 +182,11 @@ impl WorkerInner { match task.poll(&mut ctx) { TaskPollResult::Done => { // Literally nothing to do ;) - } + }, TaskPollResult::Notified => { // TODO: Think over if we rather shall use task.schedule() (which would not work right now) self.queue.push(task); - } + }, } } } diff --git a/src/kyron/src/scheduler/workers/worker.rs b/src/kyron/src/scheduler/workers/worker.rs index 0fbdcb5..22b8d5f 100644 --- a/src/kyron/src/scheduler/workers/worker.rs +++ b/src/kyron/src/scheduler/workers/worker.rs @@ -15,7 +15,9 @@ use ::core::task::Context; use core::time::Duration; use std::{rc::Rc, sync::Arc}; -use crate::scheduler::{context::ctx_get_drivers, driver::Drivers, scheduler_mt::DedicatedScheduler, waker::create_waker, workers::Thread}; +use crate::scheduler::{ + context::ctx_get_drivers, driver::Drivers, scheduler_mt::DedicatedScheduler, waker::create_waker, workers::Thread, +}; use kyron_foundation::base::fast_rand::FastRand; use kyron_foundation::containers::spmc_queue::BoundProducerConsumer; use kyron_foundation::prelude::*; @@ -135,7 +137,9 @@ impl Worker { pub(crate) fn stop(&mut self) { if let Some(scheduler) = &self.scheduler { - scheduler.get_worker_access(self.id).request_stop(&scheduler.io_unparker); + scheduler + .get_worker_access(self.id) + .request_stop(&scheduler.io_unparker); } } } @@ -150,7 +154,11 @@ impl WorkerInner { fn pre_run(&mut self, drivers: Drivers, dedicated_scheduler: Arc, with_safety: bool) { let mut builder = ContextBuilder::new(drivers) .thread_id(0) - .with_async_handle(self.producer_consumer.clone(), self.scheduler.clone(), dedicated_scheduler) + .with_async_handle( + self.producer_consumer.clone(), + self.scheduler.clone(), + dedicated_scheduler, + ) .with_worker_id(self.id); if with_safety { @@ -181,7 +189,10 @@ impl WorkerInner { } fn park_worker(&mut self) { - if self.scheduler.transition_to_parked(self.local_state == LocalState::Searching, self.id) { + if self + .scheduler + .transition_to_parked(self.local_state == LocalState::Searching, self.id) + { trace!("Last searcher is trying to sleep, inspect all work sources"); // we transition ourself but we are last one who is going to sleep, let's recheck all queues, otherwise something may stuck there @@ -218,11 +229,11 @@ impl WorkerInner { match task.poll(&mut ctx) { TaskPollResult::Done => { // Literally nothing to do ;) - } + }, TaskPollResult::Notified => { // For now stupid respawn self.scheduler.spawn_from_runtime(task, &self.producer_consumer); - } + }, } } @@ -292,7 +303,9 @@ impl WorkerInner { continue; } - let res = worker_access[real_idx].steal_handle.steal_into(&self.own_interactor.steal_handle, None); + let res = worker_access[real_idx] + .steal_handle + .steal_into(&self.own_interactor.steal_handle, None); stolen += res.unwrap_or_default(); } @@ -439,15 +452,21 @@ mod tests { scheduler: Some(scheduler.clone()), }; - worker.start(scheduler.clone(), drivers, dedicated_scheduler, ready_notifier, &thread_params); + worker.start( + scheduler.clone(), + drivers, + dedicated_scheduler, + ready_notifier, + &thread_params, + ); match barrier.wait_for_all(Duration::from_secs(5)) { Ok(_) => { debug!("Worker ready, continuing with test..."); - } + }, Err(_) => { panic!("Timeout waiting for worker to become ready"); - } + }, } // First, test that tasks are executed normally diff --git a/src/kyron/src/scheduler/workers/worker_types.rs b/src/kyron/src/scheduler/workers/worker_types.rs index 2ad72ec..af3904c 100644 --- a/src/kyron/src/scheduler/workers/worker_types.rs +++ b/src/kyron/src/scheduler/workers/worker_types.rs @@ -199,7 +199,10 @@ impl WorkerInteractor { pub fn request_stop(&self, io: &IoDriverUnparker) { let _guard = self.mtx.lock().unwrap(); // Set the state to shutting down - let prev = self.state.0.swap(WORKER_STATE_SHUTTINGDOWN, ::core::sync::atomic::Ordering::SeqCst); + let prev = self + .state + .0 + .swap(WORKER_STATE_SHUTTINGDOWN, ::core::sync::atomic::Ordering::SeqCst); if prev == WORKER_STATE_SLEEPING_CV { self.cv.notify_one(); } else if prev == WORKER_STATE_SLEEPING_IO { @@ -231,26 +234,26 @@ impl WorkerInteractor { match self.state.0.swap(WORKER_STATE_NOTIFIED, Ordering::SeqCst) { WORKER_STATE_NOTIFIED => { //Nothing to do, already someone did if for us - } + }, WORKER_STATE_SLEEPING_CV => { drop(self.mtx.lock().unwrap()); // Synchronize so worker does not lose the notification in before it goes into a wait self.cv.notify_one(); // notify without lock in case we get preempted by woken thread trace!("Unparked worker sleeping on CV"); - } + }, WORKER_STATE_SLEEPING_IO => { driver.unpark(); trace!("Unparked worker sleeping on IO"); - } + }, WORKER_STATE_EXECUTING => { //Nothing to do, looks like we already running - } + }, WORKER_STATE_SHUTTINGDOWN => { // Put back SHUTTINGDOWN state, so we can shutdown properly self.state.0.store(WORKER_STATE_SHUTTINGDOWN, Ordering::SeqCst); - } + }, _ => { panic!("Inconsistent/not handled state when unparking worker!") - } + }, }; } @@ -338,17 +341,19 @@ impl WorkerInteractor { // We were notified before, so we shall continue scheduler.transition_from_parked(self.worker_id); - self.state.0.store(WORKER_STATE_EXECUTING, ::core::sync::atomic::Ordering::SeqCst); + self.state + .0 + .store(WORKER_STATE_EXECUTING, ::core::sync::atomic::Ordering::SeqCst); debug!("Notified while try to sleep, searching again"); false - } + }, Err(WORKER_STATE_SHUTTINGDOWN) => { // If we should shutdown, we simply need to return. And the run loop exits itself. false - } + }, Err(s) => { not_recoverable_error!(with s, "Inconsistent state when parking"); - } + }, } } @@ -368,19 +373,22 @@ impl WorkerInteractor { scheduler.transition_from_parked(self.worker_id); debug!("Unparked from CV({}) by notification", info); false - } + }, Err(WORKER_STATE_SHUTTINGDOWN) => { // break here and run loop will exit false - } + }, Err(_) => { true // spurious wake-up, or any other wakeup - } + }, } } fn move_to_executing(&self, scheduler: &AsyncScheduler) { - let prev = self.state.0.swap(WORKER_STATE_EXECUTING, ::core::sync::atomic::Ordering::SeqCst); + let prev = self + .state + .0 + .swap(WORKER_STATE_EXECUTING, ::core::sync::atomic::Ordering::SeqCst); if prev == WORKER_STATE_SHUTTINGDOWN { // Put back SHUTTINGDOWN state, so we can shutdown properly diff --git a/src/kyron/src/testing/mock.rs b/src/kyron/src/testing/mock.rs index 135b0a0..bc1b49b 100644 --- a/src/kyron/src/testing/mock.rs +++ b/src/kyron/src/testing/mock.rs @@ -192,7 +192,9 @@ where MOCK_RUNTIME.with(|instance| { let mut instance = instance.borrow_mut(); - let runtime = instance.as_mut().expect("Runtime mock instance is not initialized. Did you call `init`?"); + let runtime = instance + .as_mut() + .expect("Runtime mock instance is not initialized. Did you call `init`?"); let worker_id = create_mock_worker_id(0, 0); let task = Arc::new(AsyncTask::new(boxed, &worker_id, runtime.sched.clone())); let task_ref = TaskRef::new(task); @@ -215,7 +217,9 @@ where MOCK_RUNTIME.with(|instance| { let mut instance = instance.borrow_mut(); - let runtime = instance.as_mut().expect("Runtime mock instance is not initialized. Did you call `init`?"); + let runtime = instance + .as_mut() + .expect("Runtime mock instance is not initialized. Did you call `init`?"); let worker_id = create_mock_worker_id(0, 0); let task = Arc::new(AsyncTask::new(reusable.into_pin(), &worker_id, runtime.sched.clone())); let task_ref = TaskRef::new(task); @@ -251,7 +255,9 @@ where MOCK_RUNTIME.with(|instance| { let mut instance = instance.borrow_mut(); - let runtime = instance.as_mut().expect("Runtime mock instance is not initialized. Did you call `init`?"); + let runtime = instance + .as_mut() + .expect("Runtime mock instance is not initialized. Did you call `init`?"); let worker_id = create_mock_worker_id(0, 0); let task = Arc::new(AsyncTask::new(boxed, &worker_id, runtime.sched.clone())); let task_ref = TaskRef::new(task); @@ -274,7 +280,9 @@ where MOCK_RUNTIME.with(|instance| { let mut instance = instance.borrow_mut(); - let runtime = instance.as_mut().expect("Runtime mock instance is not initialized. Did you call `init`?"); + let runtime = instance + .as_mut() + .expect("Runtime mock instance is not initialized. Did you call `init`?"); let worker_id = create_mock_worker_id(0, 0); let task = Arc::new(AsyncTask::new(reusable.into_pin(), &worker_id, runtime.sched.clone())); let task_ref = TaskRef::new(task); @@ -321,7 +329,9 @@ pub mod safety { MOCK_RUNTIME.with(|instance| { let mut instance = instance.borrow_mut(); - let runtime = instance.as_mut().expect("Runtime mock instance is not initialized. Did you call `init`?"); + let runtime = instance + .as_mut() + .expect("Runtime mock instance is not initialized. Did you call `init`?"); let worker_id = create_mock_worker_id(0, 0); let task = Arc::new(AsyncTask::new_safety(true, boxed, &worker_id, runtime.sched.clone())); let task_ref = TaskRef::new(task); @@ -342,9 +352,16 @@ pub mod safety { MOCK_RUNTIME.with(|instance| { let mut instance = instance.borrow_mut(); - let runtime = instance.as_mut().expect("Runtime mock instance is not initialized. Did you call `init`?"); + let runtime = instance + .as_mut() + .expect("Runtime mock instance is not initialized. Did you call `init`?"); let worker_id = create_mock_worker_id(0, 0); - let task = Arc::new(AsyncTask::new_safety(true, reusable.into_pin(), &worker_id, runtime.sched.clone())); + let task = Arc::new(AsyncTask::new_safety( + true, + reusable.into_pin(), + &worker_id, + runtime.sched.clone(), + )); let task_ref = TaskRef::new(task); runtime.tasks.push_back(task_ref.clone()); JoinHandle::new(task_ref) @@ -363,7 +380,10 @@ pub mod safety { spawn_from_boxed_on_dedicated(boxed, worker_id) } - pub fn spawn_from_boxed_on_dedicated(boxed: FutureBox>, _worker_id: UniqueWorkerId) -> JoinHandle> + pub fn spawn_from_boxed_on_dedicated( + boxed: FutureBox>, + _worker_id: UniqueWorkerId, + ) -> JoinHandle> where T: Send + 'static, E: Send + 'static, @@ -374,7 +394,9 @@ pub mod safety { MOCK_RUNTIME.with(|instance| { let mut instance = instance.borrow_mut(); - let runtime = instance.as_mut().expect("Runtime mock instance is not initialized. Did you call `init`?"); + let runtime = instance + .as_mut() + .expect("Runtime mock instance is not initialized. Did you call `init`?"); let worker_id = create_mock_worker_id(0, 0); let task = Arc::new(AsyncTask::new_safety(true, boxed, &worker_id, runtime.sched.clone())); let task_ref = TaskRef::new(task); @@ -398,9 +420,16 @@ pub mod safety { MOCK_RUNTIME.with(|instance| { let mut instance = instance.borrow_mut(); - let runtime = instance.as_mut().expect("Runtime mock instance is not initialized. Did you call `init`?"); + let runtime = instance + .as_mut() + .expect("Runtime mock instance is not initialized. Did you call `init`?"); let worker_id = create_mock_worker_id(0, 0); - let task = Arc::new(AsyncTask::new_safety(true, reusable.into_pin(), &worker_id, runtime.sched.clone())); + let task = Arc::new(AsyncTask::new_safety( + true, + reusable.into_pin(), + &worker_id, + runtime.sched.clone(), + )); let task_ref = TaskRef::new(task); runtime.tasks.push_back(task_ref.clone()); JoinHandle::new(task_ref) diff --git a/src/kyron/src/testing/mod.rs b/src/kyron/src/testing/mod.rs index fb831d0..04c1ceb 100644 --- a/src/kyron/src/testing/mod.rs +++ b/src/kyron/src/testing/mod.rs @@ -91,7 +91,8 @@ impl SchedulerTrait for SchedulerMock { } fn respawn_into_safety(&self, _: TaskRef) { - self.safety_spawn_count.fetch_add(1, ::core::sync::atomic::Ordering::SeqCst); + self.safety_spawn_count + .fetch_add(1, ::core::sync::atomic::Ordering::SeqCst); } } @@ -122,7 +123,11 @@ pub(crate) type WakerTask = Arc + Send pub(crate) fn get_dummy_task_waker() -> (Waker, WakerTask) { let worker_id = create_mock_worker_id(0, 0); - let task = Arc::new(AsyncTask::new(box_future(async {}), &worker_id, create_mock_scheduler())); + let task = Arc::new(AsyncTask::new( + box_future(async {}), + &worker_id, + create_mock_scheduler(), + )); (create_waker(TaskRef::new(task.clone())), task) } diff --git a/src/kyron/src/time/clock.rs b/src/kyron/src/time/clock.rs index b8490ba..e788432 100644 --- a/src/kyron/src/time/clock.rs +++ b/src/kyron/src/time/clock.rs @@ -48,7 +48,11 @@ impl Sub for Instant { type Output = Instant; fn sub(self, rhs: Duration) -> Self::Output { - Instant(self.0.checked_sub(rhs).expect("overflow when subtracting duration from instant")) + Instant( + self.0 + .checked_sub(rhs) + .expect("overflow when subtracting duration from instant"), + ) } } @@ -56,7 +60,11 @@ impl Add for Instant { type Output = Instant; fn add(self, rhs: Duration) -> Self::Output { - Instant(self.0.checked_add(rhs).expect("overflow when adding duration to instant")) + Instant( + self.0 + .checked_add(rhs) + .expect("overflow when adding duration to instant"), + ) } } diff --git a/src/kyron/src/time/mod.rs b/src/kyron/src/time/mod.rs index ec7979e..d96562a 100644 --- a/src/kyron/src/time/mod.rs +++ b/src/kyron/src/time/mod.rs @@ -98,7 +98,12 @@ impl TimeDriver { /// pub fn next_process_time(&self, wait_on_access: bool) -> Option { if wait_on_access { - return self.inner.write().unwrap().next_process_time().map(|(instant, _)| instant); + return self + .inner + .write() + .unwrap() + .next_process_time() + .map(|(instant, _)| instant); } else { match self.inner.try_write() { Ok(mut inner) => inner.next_process_time().map(|(instant, _)| instant), @@ -220,12 +225,12 @@ impl Inner { Some(info) if info.deadline <= now => { self.process_expired(&info); self.set_last_check_time(info.deadline); // advance last_check_time to the expiration time since this is where we are now - } + }, _ => { // finally. no one expires so we can set current processing time self.set_last_check_time(now); break; - } + }, } } } @@ -280,7 +285,9 @@ impl Inner { // API assumes that expire_at_msec fits into MAX_TIMEOUT_TIME fn register_timeout_internal(&self, expire_at_msec: u64, waker: Waker) -> Result<(), CommonErrors> { - let entry = self.allocate_entry(waker, expire_at_msec).map_err(|_| CommonErrors::NoSpaceLeft)?; + let entry = self + .allocate_entry(waker, expire_at_msec) + .map_err(|_| CommonErrors::NoSpaceLeft)?; let level = self.compute_level_for_timer(self.last_check_time, expire_at_msec); self.levels[level].register_wakeup_on_timeout(expire_at_msec, entry); @@ -321,7 +328,10 @@ impl Inner { } fn instant_into_u64(&self, now: Instant) -> u64 { - now.saturating_duration_since(self.start_time).as_millis().try_into().unwrap_or(u64::MAX) + now.saturating_duration_since(self.start_time) + .as_millis() + .try_into() + .unwrap_or(u64::MAX) } } @@ -494,11 +504,17 @@ mod tests { driver.register_timeout(reg_time, waker.clone()).unwrap(); let poll_time = Clock::now(); - assert!(poll_time > reg_time, "Poll time should not be equal to registration time"); + assert!( + poll_time > reg_time, + "Poll time should not be equal to registration time" + ); driver.process_timeouts(poll_time); - assert_eq!(driver.register_timeout(reg_time, waker.clone()), Err(CommonErrors::AlreadyDone)); + assert_eq!( + driver.register_timeout(reg_time, waker.clone()), + Err(CommonErrors::AlreadyDone) + ); } #[test] @@ -511,8 +527,13 @@ mod tests { let waker: Waker = mock.into_arc().into(); - let reg_time = Clock::now().checked_add(Duration::from_millis(MAX_TIMEOUT_TIME + 1)).unwrap(); - assert_eq!(driver.register_timeout(reg_time, waker.clone()), Err(CommonErrors::WrongArgs)); + let reg_time = Clock::now() + .checked_add(Duration::from_millis(MAX_TIMEOUT_TIME + 1)) + .unwrap(); + assert_eq!( + driver.register_timeout(reg_time, waker.clone()), + Err(CommonErrors::WrongArgs) + ); } struct SimpleRng { @@ -523,7 +544,10 @@ mod tests { impl SimpleRng { #[allow(dead_code)] fn new() -> Self { - let seed = SystemTime::now().duration_since(UNIX_EPOCH).expect("Time went backwards").as_nanos() as u64; + let seed = SystemTime::now() + .duration_since(UNIX_EPOCH) + .expect("Time went backwards") + .as_nanos() as u64; SimpleRng { seed, state: seed } } @@ -585,7 +609,7 @@ mod tests { for (i, t) in timeouts.iter().enumerate() { match driver.register_timeout_internal(*t, waker.clone()) { - Ok(_) => {} + Ok(_) => {}, Err(e) => panic!("Failed to register timeout at {} with {:?}, iter {}", t, e, i), } } @@ -604,16 +628,34 @@ mod tests { let before = prev + rng.next_u32() % (current - prev); driver.process_internal(before); - assert_eq!(current_call_times, mock.times(), "Polled in {} should timeout in {}", before, current); // Nothing shall change + assert_eq!( + current_call_times, + mock.times(), + "Polled in {} should timeout in {}", + before, + current + ); // Nothing shall change driver.process_internal(current); current_call_times += 1; - assert_eq!(current_call_times, mock.times(), "Polled in {} should timeout in {}", current, current); // Shall fire + assert_eq!( + current_call_times, + mock.times(), + "Polled in {} should timeout in {}", + current, + current + ); // Shall fire let after = current + rng.next_u32() % (next - current); driver.process_internal(after); - assert_eq!(current_call_times, mock.times(), "Polled in {} already timeout at {}", after, current); // Nothing shall change + assert_eq!( + current_call_times, + mock.times(), + "Polled in {} already timeout at {}", + after, + current + ); // Nothing shall change prev = after; } @@ -643,7 +685,7 @@ mod tests { } index + reps - } + }, Err(index) => index, } } @@ -673,7 +715,7 @@ mod tests { for (i, t) in timeouts.iter().enumerate() { match driver.register_timeout_internal(*t, waker.clone()) { - Ok(_) => {} + Ok(_) => {}, Err(e) => panic!("Failed to register timeout at {} with {:?}, iter {}", t, e, i), } } @@ -684,7 +726,13 @@ mod tests { for p in poll_times { let cnt_before = count_less_eq_than(&timeouts, &p); driver.process_internal(p); - assert_eq!(cnt_before, mock.times(), "Polled in {} should now be called {} times", p, cnt_before); + assert_eq!( + cnt_before, + mock.times(), + "Polled in {} should now be called {} times", + p, + cnt_before + ); } } @@ -744,7 +792,7 @@ mod tests { for (i, t) in timeouts.iter().enumerate() { match driver.register_timeout_internal(*t, waker.clone()) { - Ok(_) => {} + Ok(_) => {}, Err(e) => panic!("Failed to register timeout at {} with {:?}, iter {}", t, e, i), } } @@ -754,7 +802,13 @@ mod tests { for p in poll_times { let cnt_before = count_less_eq_than(&timeouts, &p); driver.process_internal(p); - assert_eq!(cnt_before, mock.times(), "Polled in {} should now be called {} times", p, cnt_before); + assert_eq!( + cnt_before, + mock.times(), + "Polled in {} should now be called {} times", + p, + cnt_before + ); } } } diff --git a/src/kyron/src/time/wheel.rs b/src/kyron/src/time/wheel.rs index 63d791f..3d389cd 100644 --- a/src/kyron/src/time/wheel.rs +++ b/src/kyron/src/time/wheel.rs @@ -140,11 +140,16 @@ impl TimeWheel { } pub(super) fn aquire_slot(&mut self, info: &ExpireInfo) -> TimeSlotIterator { - assert!(info.level == self.level, "Trying to acquire slot from a different level"); + assert!( + info.level == self.level, + "Trying to acquire slot from a different level" + ); self.occupied_slots.fetch_and(!(1 << info.slot_id), Ordering::Relaxed); - let entries = self.slots[info.slot_id as usize].head.swap(::core::ptr::null_mut(), Ordering::Relaxed); + let entries = self.slots[info.slot_id as usize] + .head + .swap(::core::ptr::null_mut(), Ordering::Relaxed); TimeSlotIterator { head: entries } } @@ -165,11 +170,11 @@ impl TimeWheel { { Ok(_) => { break; // Head points to new item, we can exit the loop - } + }, Err(_) => { // If the head was changed, we retry continue; - } + }, } } } diff --git a/src/logging_tracing/src/tracing.rs b/src/logging_tracing/src/tracing.rs index 5fb5ea9..e58e4dd 100644 --- a/src/logging_tracing/src/tracing.rs +++ b/src/logging_tracing/src/tracing.rs @@ -65,7 +65,7 @@ impl TryFrom for TracingLibraryImpl { Some(l) => l.and_then(perfetto_layer).boxed(), None => perfetto_layer.boxed(), }) - } + }, TraceScope::SystemScope => { let perfetto_layer = layer::SdkLayer::from_config(system_trace_config(), None) .with_enable_system(true) @@ -76,7 +76,7 @@ impl TryFrom for TracingLibraryImpl { Some(l) => l.and_then(perfetto_layer).boxed(), None => perfetto_layer.boxed(), }) - } + }, } } diff --git a/src/xtask/src/main.rs b/src/xtask/src/main.rs index 1450c5d..5b8551f 100644 --- a/src/xtask/src/main.rs +++ b/src/xtask/src/main.rs @@ -42,26 +42,44 @@ fn main() { match command.as_str() { "build" => { debug_build(envs, cli_env_vars, &passthrough_args); - } + }, "clippy" => { clippy(envs, cli_env_vars, &passthrough_args); - } + }, "run" => { run_build("debug_build", &["run"], envs, cli_env_vars, &passthrough_args); - } + }, "build:release" => { - run_build("release_build", &["build", "--release"], envs, cli_env_vars, &passthrough_args); - } + run_build( + "release_build", + &["build", "--release"], + envs, + cli_env_vars, + &passthrough_args, + ); + }, "run:release" => { - run_build("release_build", &["run", "--release"], envs, cli_env_vars, &passthrough_args); - } + run_build( + "release_build", + &["run", "--release"], + envs, + cli_env_vars, + &passthrough_args, + ); + }, "build:test" | "test" => { test(envs, cli_env_vars, &passthrough_args); - } + }, "build:loom" => { envs.insert("RUSTFLAGS".into(), "--cfg loom".into()); - run_build("loom_build", &["test", "--release"], envs, cli_env_vars, &passthrough_args); - } + run_build( + "loom_build", + &["test", "--release"], + envs, + cli_env_vars, + &passthrough_args, + ); + }, "build:qnx_x86_64" => { run_build( "", @@ -70,7 +88,7 @@ fn main() { cli_env_vars, &passthrough_args, ); - } + }, "build:qnx_arm" => { run_build( "", @@ -79,10 +97,10 @@ fn main() { cli_env_vars, &passthrough_args, ); - } + }, "check_lic" => { check_license_header(); - } + }, "check" => { check_license_header(); run_command( @@ -94,7 +112,7 @@ fn main() { debug_build(envs.clone(), cli_env_vars.clone(), &passthrough_args); clippy(envs.clone(), cli_env_vars.clone(), &passthrough_args); test(envs, cli_env_vars, &passthrough_args); - } + }, "build:scenarios" => { run_build( "debug_build", @@ -103,7 +121,7 @@ fn main() { cli_env_vars, &passthrough_args, ); - } + }, "run:scenarios" => { run_build( "debug_build", @@ -118,7 +136,7 @@ fn main() { cli_env_vars, &passthrough_args, ); - } + }, _ => print_usage_and_exit(), } } @@ -159,7 +177,12 @@ fn run_build( run_command(cargo_args, default_envs, extra_args, None); } -fn run_command(cargo_args: &[&str], default_envs: HashMap, extra_args: &[String], explain: Option<&str>) { +fn run_command( + cargo_args: &[&str], + default_envs: HashMap, + extra_args: &[String], + explain: Option<&str>, +) { let mut cmd = Command::new("cargo"); cmd.args(cargo_args); cmd.args(extra_args); @@ -171,7 +194,9 @@ fn run_command(cargo_args: &[&str], default_envs: HashMap, extra println!("> Running: cargo {} {}", cargo_args.join(" "), extra_args.join(" ")); println!("> With envs: {:?}", default_envs); - let status = cmd.status().unwrap_or_else(|_| panic!("Failed to run cargo with explain {:?}", explain)); + let status = cmd + .status() + .unwrap_or_else(|_| panic!("Failed to run cargo with explain {:?}", explain)); if !status.success() { exit(status.code().unwrap_or(1)); } @@ -212,7 +237,9 @@ const REQUIRED_HEADER: &str = r#"// ******************************************** "#; fn check_license_header() { - let project_dir = std::env::current_dir().expect("Failed to get current directory").join("src"); + let project_dir = std::env::current_dir() + .expect("Failed to get current directory") + .join("src"); let mut missing_header_files = Vec::new(); visit_dirs(&project_dir, &mut missing_header_files); diff --git a/tests/test_scenarios/rust/src/internals/net_helper.rs b/tests/test_scenarios/rust/src/internals/net_helper.rs index 20e236e..4b3e23a 100644 --- a/tests/test_scenarios/rust/src/internals/net_helper.rs +++ b/tests/test_scenarios/rust/src/internals/net_helper.rs @@ -73,7 +73,9 @@ pub async fn create_tcp_listener(connection_parameters: ConnectionParameters) -> } pub async fn create_tcp_stream(connection_parameters: ConnectionParameters) -> TcpStream { - let stream = TcpStream::connect(connection_parameters.address).await.expect("Failed to connect"); + let stream = TcpStream::connect(connection_parameters.address) + .await + .expect("Failed to connect"); // Set optional TTL. if let Some(ttl) = connection_parameters.ttl { diff --git a/tests/test_scenarios/rust/src/internals/runtime_helper.rs b/tests/test_scenarios/rust/src/internals/runtime_helper.rs index 3670339..fcd56b6 100644 --- a/tests/test_scenarios/rust/src/internals/runtime_helper.rs +++ b/tests/test_scenarios/rust/src/internals/runtime_helper.rs @@ -104,7 +104,10 @@ impl Runtime { } pub fn build(&self) -> kyron::runtime::Runtime { - debug!("Creating kyron::Runtime with {} execution engines", self.exec_engines.len()); + debug!( + "Creating kyron::Runtime with {} execution engines", + self.exec_engines.len() + ); let mut async_rt_builder = kyron::runtime::RuntimeBuilder::new(); for exec_engine in self.exec_engines.as_slice() { @@ -140,7 +143,8 @@ impl Runtime { // Create `UniqueWorkerId`. let unique_worker_id = UniqueWorkerId::from(&dedicated_worker.id); - exec_engine_builder = exec_engine_builder.with_dedicated_worker(unique_worker_id, async_rt_thread_params); + exec_engine_builder = + exec_engine_builder.with_dedicated_worker(unique_worker_id, async_rt_thread_params); } } diff --git a/tests/test_scenarios/rust/src/internals/thread_params.rs b/tests/test_scenarios/rust/src/internals/thread_params.rs index 9f5fff9..e111012 100644 --- a/tests/test_scenarios/rust/src/internals/thread_params.rs +++ b/tests/test_scenarios/rust/src/internals/thread_params.rs @@ -90,7 +90,11 @@ pub fn current_thread_priority_params() -> ThreadPriorityParams { let thread = libc::pthread_self(); let mut policy: libc::c_int = -1; let mut param = MaybeUninit::::zeroed().assume_init(); - let rc = libc::pthread_getschedparam(thread, &mut policy as *mut libc::c_int, &mut param as *mut libc::sched_param); + let rc = libc::pthread_getschedparam( + thread, + &mut policy as *mut libc::c_int, + &mut param as *mut libc::sched_param, + ); if rc != 0 { let errno = *libc::__errno_location(); panic!("libc::pthread_getschedparam failed, rc: {rc}, errno: {errno}"); diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/channel/spmc_broadcast.rs b/tests/test_scenarios/rust/src/scenarios/runtime/channel/spmc_broadcast.rs index fed5b84..3f34ec0 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/channel/spmc_broadcast.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/channel/spmc_broadcast.rs @@ -37,7 +37,8 @@ struct TestInput { impl TestInput { pub fn new(input: &str) -> Self { let v: Value = serde_json::from_str(input).expect("Failed to parse input JSON string in TestInput::new"); - serde_json::from_value(v["test"].clone()).expect("Failed to parse 'test' field from input JSON in TestInput::new") + serde_json::from_value(v["test"].clone()) + .expect("Failed to parse 'test' field from input JSON in TestInput::new") } } @@ -46,7 +47,7 @@ fn send_value(sender: &spmc_broadcast::Sender, val match result { Err(e) => { info!(id = "send_task", error = format!("{e:?}")); - } + }, Ok(_) => info!(id = "send_task", data = value), } } @@ -61,21 +62,29 @@ async fn send_task(sender: spmc_broadcast::Sender, send_data(&sender, &data_to_send); } -async fn receive_data(name: &str, receiver: &mut spmc_broadcast::Receiver, read_data_count: usize) { +async fn receive_data( + name: &str, + receiver: &mut spmc_broadcast::Receiver, + read_data_count: usize, +) { for _ndx in 0..read_data_count { let result = receiver.recv().await; match result { Some(val) => { info!(id = name, data = val); - } + }, None => { info!(id = name, error = "Provider dropped"); - } + }, } } } -async fn receive_task(name: String, mut receiver: spmc_broadcast::Receiver, read_data_count: usize) { +async fn receive_task( + name: String, + mut receiver: spmc_broadcast::Receiver, + read_data_count: usize, +) { receive_data(&name, &mut receiver, read_data_count).await; } @@ -132,8 +141,10 @@ struct OverflowTestInput { impl OverflowTestInput { pub fn new(input: &str) -> Self { - let v: Value = serde_json::from_str(input).expect("Failed to parse input JSON string in OverflowTestInput::new"); - serde_json::from_value(v["test"].clone()).expect("Failed to parse 'test' field from input JSON in OverflowTestInput::new") + let v: Value = + serde_json::from_str(input).expect("Failed to parse input JSON string in OverflowTestInput::new"); + serde_json::from_value(v["test"].clone()) + .expect("Failed to parse 'test' field from input JSON in OverflowTestInput::new") } } @@ -153,7 +164,7 @@ impl SPMCBroadcastCreateReceiversOnly { Some(cloned) => receivers.push(cloned), None => { info!(id = "receivers_handle_overflow"); - } + }, } } @@ -175,7 +186,7 @@ impl SPMCBroadcastCreateReceiversOnly { Some(subscribed) => receivers.push(subscribed), None => { info!(id = "receivers_handle_overflow"); - } + }, } } @@ -229,7 +240,7 @@ impl SPMCBroadcastNumOfSubscribers { Some(cloned) => receivers.push(cloned), None => { info!(id = "receivers_handle_overflow"); - } + }, } Self::log_subscriber_count(sender, "add_receiver"); } @@ -252,7 +263,7 @@ impl SPMCBroadcastNumOfSubscribers { Some(subscribed) => receivers.push(subscribed), None => { info!(id = "receivers_handle_overflow"); - } + }, } Self::log_subscriber_count(sender, "add_receiver"); } @@ -579,7 +590,8 @@ struct HeavyTestInput { impl HeavyTestInput { pub fn new(input: &str) -> Self { let v: Value = serde_json::from_str(input).expect("Failed to parse input JSON string in HeavyTestInput::new"); - serde_json::from_value(v["test"].clone()).expect("Failed to parse 'test' field from input JSON in HeavyTestInput::new") + serde_json::from_value(v["test"].clone()) + .expect("Failed to parse 'test' field from input JSON in HeavyTestInput::new") } } @@ -599,7 +611,7 @@ impl SPMCBroadcastHeavyLoad { } else { panic!("Unexpected error: {e:?}"); } - } + }, Ok(_) => break, } } @@ -611,18 +623,26 @@ impl SPMCBroadcastHeavyLoad { } } - async fn heavy_receive_task(name: String, mut receiver: spmc_broadcast::Receiver, expected_data_count: u64) { + async fn heavy_receive_task( + name: String, + mut receiver: spmc_broadcast::Receiver, + expected_data_count: u64, + ) { for expected_val in 0..expected_data_count { let result = receiver.recv().await; match result { Some(val) => { if val != expected_val { - info!(id = name, iter = expected_val, error = format!("Expected {expected_val}, got {val}")); + info!( + id = name, + iter = expected_val, + error = format!("Expected {expected_val}, got {val}") + ); } - } + }, None => { info!(id = name, iter = expected_val, error = "Provider dropped"); - } + }, } } } diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/channel/spsc.rs b/tests/test_scenarios/rust/src/scenarios/runtime/channel/spsc.rs index 70b9f15..78510f7 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/channel/spsc.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/channel/spsc.rs @@ -45,7 +45,7 @@ async fn send_task(sender: spsc::Sender, data_to_s match result { Err(e) => { info!(id = "send_task", error = format!("{e:?}")); - } + }, Ok(_) => info!(id = "send_task", data = data), } } @@ -57,10 +57,10 @@ async fn receive_task(mut receiver: spsc::Receiver match result { Some(val) => { info!(id = "receive_task", data = val); - } + }, None => { info!(id = "receive_task", error = "Provider dropped"); - } + }, } } } @@ -110,7 +110,9 @@ impl Scenario for SPSCSendOnly { let (sender, _receiver) = spsc::create_channel::(); rt.block_on(async move { - spawn(send_task(sender, logic.data_to_send.clone())).await.expect("Failed to spawn task"); + spawn(send_task(sender, logic.data_to_send.clone())) + .await + .expect("Failed to spawn task"); }); Ok(()) @@ -135,7 +137,9 @@ impl Scenario for SPSCDropReceiver { drop(receiver); rt.block_on(async move { - spawn(send_task(sender, logic.data_to_send.clone())).await.expect("Failed to spawn task"); + spawn(send_task(sender, logic.data_to_send.clone())) + .await + .expect("Failed to spawn task"); }); Ok(()) @@ -200,7 +204,10 @@ impl Scenario for SPSCDropSenderInTheMiddle { let mut joiner = RuntimeJoiner::new(); rt.block_on(async move { joiner.add_handle(spawn(send_task(sender, logic.data_to_send.clone()))); - joiner.add_handle(spawn(receive_task(receiver, logic.data_to_send.len() + logic.overread_count))); + joiner.add_handle(spawn(receive_task( + receiver, + logic.data_to_send.len() + logic.overread_count, + ))); joiner.wait_for_all().await; }); @@ -229,7 +236,7 @@ impl SPSCDropReceiverInTheMiddle { match result { Err(e) => { info!(id = "send_task", error = format!("{e:?}")); - } + }, Ok(_) => info!(id = "send_task", data = data), } } @@ -316,7 +323,7 @@ impl SPSCHeavyLoad { } else { panic!("Unexpected error: {e:?}"); } - } + }, Ok(_) => break, } } @@ -328,7 +335,10 @@ impl SPSCHeavyLoad { } } - pub async fn heavy_receive_task(mut receiver: spsc::Receiver, expected_data_count: u64) { + pub async fn heavy_receive_task( + mut receiver: spsc::Receiver, + expected_data_count: u64, + ) { for expected_val in 1..=expected_data_count { let result = receiver.recv().await; match result { @@ -340,10 +350,10 @@ impl SPSCHeavyLoad { error = format!("Expected {expected_val}, got {val}") ); } - } + }, None => { info!(id = "receive_task", iter = expected_val, error = "Provider dropped"); - } + }, } } } diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/net/mod.rs b/tests/test_scenarios/rust/src/scenarios/runtime/net/mod.rs index 7832c2b..ac0b348 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/net/mod.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/net/mod.rs @@ -19,5 +19,9 @@ use crate::scenarios::runtime::net::udp::udp_scenario_group; use test_scenarios_rust::scenario::{ScenarioGroup, ScenarioGroupImpl}; pub fn net_scenario_group() -> Box { - Box::new(ScenarioGroupImpl::new("net", vec![], vec![tcp_scenario_group(), udp_scenario_group()])) + Box::new(ScenarioGroupImpl::new( + "net", + vec![], + vec![tcp_scenario_group(), udp_scenario_group()], + )) } diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/mod.rs b/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/mod.rs index 28a2789..59be88c 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/mod.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/mod.rs @@ -35,7 +35,10 @@ async fn handle_connection_with_echo_response(mut stream: TcpStream) { // Addresses. let peer_addr = stream.peer_addr().expect("Failed to get peer address"); let local_addr = stream.local_addr().expect("Failed to get local address"); - info!(peer_addr = format!("{peer_addr:?}"), local_addr = format!("{local_addr:?}")); + info!( + peer_addr = format!("{peer_addr:?}"), + local_addr = format!("{local_addr:?}") + ); // Read. let mut buf = [0u8; 1024]; @@ -43,13 +46,13 @@ async fn handle_connection_with_echo_response(mut stream: TcpStream) { match stream.read(&mut buf).await { Ok(0) => { info!("Client closed connection"); - } + }, Ok(n) => { info!("Read {n} bytes"); - } + }, Err(e) => { info!("Read error: {e:?}"); - } + }, } let message_read = String::from_utf8(buf.to_vec()).expect("Failed to convert string from bytes"); @@ -62,12 +65,12 @@ async fn handle_connection_with_echo_response(mut stream: TcpStream) { match stream.write(data).await { Ok(0) => { info!("Client closed connection during write"); - } + }, Ok(n) => { info!("Written {n} bytes"); - } + }, Err(e) => { info!("Write error: {e:?}"); - } + }, } } diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/server.rs b/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/server.rs index e8d8318..f03801d 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/server.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/server.rs @@ -31,13 +31,17 @@ impl Scenario for TcpServer { fn run(&self, input: &str) -> Result<(), String> { let mut rt = Runtime::from_json(input)?.build(); - let connection_parameters = ConnectionParameters::from_json(input).expect("Failed to parse connection parameters"); + let connection_parameters = + ConnectionParameters::from_json(input).expect("Failed to parse connection parameters"); rt.block_on(async move { info!("Program entered engine"); let listener = create_tcp_listener(connection_parameters).await; - info!("TCP server listening on {}", listener.local_addr().expect("Failed to get local address")); + info!( + "TCP server listening on {}", + listener.local_addr().expect("Failed to get local address") + ); // Loop is expected to be terminated by SIGTERM from Python test. loop { @@ -59,7 +63,10 @@ async fn handle_connection_no_response(mut stream: TcpStream) { // Addresses. let peer_addr = stream.peer_addr().expect("Failed to get peer address"); let local_addr = stream.local_addr().expect("Failed to get local address"); - info!(peer_addr = format!("{peer_addr:?}"), local_addr = format!("{local_addr:?}")); + info!( + peer_addr = format!("{peer_addr:?}"), + local_addr = format!("{local_addr:?}") + ); // Read. let mut buf = [0u8; 1024]; @@ -68,15 +75,15 @@ async fn handle_connection_no_response(mut stream: TcpStream) { Ok(0) => { info!("Client closed connection"); 0 - } + }, Ok(n) => { info!("Read {n} bytes"); n - } + }, Err(e) => { info!("Read error: {e:?}"); 0 - } + }, }; let message_read = String::from_utf8(buf[..n].to_vec()).expect("Failed to convert string from bytes"); @@ -91,13 +98,17 @@ impl Scenario for TcpNoResponseServer { fn run(&self, input: &str) -> Result<(), String> { let mut rt = Runtime::from_json(input)?.build(); - let connection_parameters = ConnectionParameters::from_json(input).expect("Failed to parse connection parameters"); + let connection_parameters = + ConnectionParameters::from_json(input).expect("Failed to parse connection parameters"); rt.block_on(async move { info!("Program entered engine"); let listener = create_tcp_listener(connection_parameters).await; - info!("TCP server listening on {}", listener.local_addr().expect("Failed to get local address")); + info!( + "TCP server listening on {}", + listener.local_addr().expect("Failed to get local address") + ); // Loop is expected to be terminated by SIGTERM from Python test. loop { @@ -120,7 +131,10 @@ pub async fn handle_connection_with_poll(mut stream: TcpStream) -> Result<(), Er // Addresses. let peer_addr = stream.peer_addr().expect("Failed to get peer address"); let local_addr = stream.local_addr().expect("Failed to get local address"); - info!(peer_addr = format!("{peer_addr:?}"), local_addr = format!("{local_addr:?}")); + info!( + peer_addr = format!("{peer_addr:?}"), + local_addr = format!("{local_addr:?}") + ); // Read let mut buf = [0u8; 1024]; @@ -169,13 +183,17 @@ impl Scenario for TcpPollWriteServer { fn run(&self, input: &str) -> Result<(), String> { let mut rt = Runtime::from_json(input)?.build(); - let connection_parameters = ConnectionParameters::from_json(input).expect("Failed to parse connection parameters"); + let connection_parameters = + ConnectionParameters::from_json(input).expect("Failed to parse connection parameters"); rt.block_on(async move { info!("Program entered engine"); let listener = create_tcp_listener(connection_parameters).await; - info!("TCP server listening on {}", listener.local_addr().expect("Failed to get local address")); + info!( + "TCP server listening on {}", + listener.local_addr().expect("Failed to get local address") + ); // Loop is expected to be terminated by SIGTERM from Python test. loop { @@ -197,7 +215,11 @@ impl Scenario for TcpPollWriteServer { pub fn server_group() -> Box { Box::new(ScenarioGroupImpl::new( "server", - vec![Box::new(TcpServer), Box::new(TcpNoResponseServer), Box::new(TcpPollWriteServer)], + vec![ + Box::new(TcpServer), + Box::new(TcpNoResponseServer), + Box::new(TcpPollWriteServer), + ], vec![], )) } diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/tcp_listener.rs b/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/tcp_listener.rs index 927c13c..dba990d 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/tcp_listener.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/tcp_listener.rs @@ -27,11 +27,15 @@ impl Scenario for Smoke { fn run(&self, input: &str) -> Result<(), String> { let mut rt = Runtime::from_json(input)?.build(); - let connection_parameters = ConnectionParameters::from_json(input).expect("Failed to parse connection parameters"); + let connection_parameters = + ConnectionParameters::from_json(input).expect("Failed to parse connection parameters"); rt.block_on(async move { let listener = create_tcp_listener(connection_parameters).await; - info!("TCP server listening on {}", listener.local_addr().expect("Failed to get local address")); + info!( + "TCP server listening on {}", + listener.local_addr().expect("Failed to get local address") + ); // Loop is expected to be terminated by SIGTERM from Python test. loop { @@ -58,7 +62,8 @@ impl Scenario for SetGetTtl { fn run(&self, input: &str) -> Result<(), String> { let mut rt = Runtime::from_json(input)?.build(); - let connection_parameters = ConnectionParameters::from_json(input).expect("Failed to parse connection parameters"); + let connection_parameters = + ConnectionParameters::from_json(input).expect("Failed to parse connection parameters"); rt.block_on(async move { let listener = create_tcp_listener(connection_parameters).await; @@ -70,5 +75,9 @@ impl Scenario for SetGetTtl { } pub fn tcp_listener_group() -> Box { - Box::new(ScenarioGroupImpl::new("tcp_listener", vec![Box::new(Smoke), Box::new(SetGetTtl)], vec![])) + Box::new(ScenarioGroupImpl::new( + "tcp_listener", + vec![Box::new(Smoke), Box::new(SetGetTtl)], + vec![], + )) } diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/tcp_stream.rs b/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/tcp_stream.rs index 193f414..2d23de6 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/tcp_stream.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/net/tcp/tcp_stream.rs @@ -21,14 +21,20 @@ use tracing::info; fn parse_message(input: &str) -> String { let input_content: Value = serde_json::from_str(input).expect("Failed to parse input string"); - input_content["message"].as_str().expect("Failed to parse \"message\" field").to_string() + input_content["message"] + .as_str() + .expect("Failed to parse \"message\" field") + .to_string() } async fn write_and_read_task(mut stream: TcpStream, message: String) { // Addresses. let peer_addr = stream.peer_addr().expect("Failed to get peer address"); let local_addr = stream.local_addr().expect("Failed to get local address"); - info!(peer_addr = format!("{peer_addr:?}"), local_addr = format!("{local_addr:?}")); + info!( + peer_addr = format!("{peer_addr:?}"), + local_addr = format!("{local_addr:?}") + ); // Write. { @@ -40,14 +46,14 @@ async fn write_and_read_task(mut stream: TcpStream, message: String) { Ok(0) => { info!("Client closed connection during write"); return; - } + }, Ok(n) => { info!("Written {n} bytes"); - } + }, Err(e) => { info!("Write error: {e:?}"); return; - } + }, } } @@ -57,13 +63,13 @@ async fn write_and_read_task(mut stream: TcpStream, message: String) { match stream.read(&mut read_buf).await { Ok(0) => { info!("Client closed connection"); - } + }, Ok(n) => { info!("Read {n} bytes"); - } + }, Err(e) => { info!("Read error: {e:?}"); - } + }, }; let message_read = String::from_utf8(read_buf.to_vec()).expect("Failed to convert string from bytes"); @@ -81,7 +87,8 @@ impl Scenario for Smoke { fn run(&self, input: &str) -> Result<(), String> { let mut rt = Runtime::from_json(input)?.build(); - let connection_parameters = ConnectionParameters::from_json(input).expect("Failed to parse connection parameters"); + let connection_parameters = + ConnectionParameters::from_json(input).expect("Failed to parse connection parameters"); let message = parse_message(input); rt.block_on(async move { @@ -107,7 +114,8 @@ impl Scenario for SetGetTtl { fn run(&self, input: &str) -> Result<(), String> { let mut rt = Runtime::from_json(input)?.build(); - let connection_parameters = ConnectionParameters::from_json(input).expect("Failed to parse connection parameters"); + let connection_parameters = + ConnectionParameters::from_json(input).expect("Failed to parse connection parameters"); rt.block_on(async move { let stream = create_tcp_stream(connection_parameters).await; @@ -119,5 +127,9 @@ impl Scenario for SetGetTtl { } pub fn tcp_stream_group() -> Box { - Box::new(ScenarioGroupImpl::new("tcp_stream", vec![Box::new(Smoke), Box::new(SetGetTtl)], vec![])) + Box::new(ScenarioGroupImpl::new( + "tcp_stream", + vec![Box::new(Smoke), Box::new(SetGetTtl)], + vec![], + )) } diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/net/udp/mod.rs b/tests/test_scenarios/rust/src/scenarios/runtime/net/udp/mod.rs index 6d162ff..7d4eec6 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/net/udp/mod.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/net/udp/mod.rs @@ -19,5 +19,9 @@ use udp_server::udp_server_group; use test_scenarios_rust::scenario::{ScenarioGroup, ScenarioGroupImpl}; pub fn udp_scenario_group() -> Box { - Box::new(ScenarioGroupImpl::new("udp", vec![], vec![udp_client_group(), udp_server_group()])) + Box::new(ScenarioGroupImpl::new( + "udp", + vec![], + vec![udp_client_group(), udp_server_group()], + )) } diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/net/udp/udp_client.rs b/tests/test_scenarios/rust/src/scenarios/runtime/net/udp/udp_client.rs index f3c11a3..7264aba 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/net/udp/udp_client.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/net/udp/udp_client.rs @@ -21,7 +21,10 @@ use tracing::{debug, info}; fn parse_message(input: &str) -> String { let input_content: Value = serde_json::from_str(input).expect("Failed to parse input string"); - input_content["message"].as_str().expect("Failed to parse \"message\" field").to_string() + input_content["message"] + .as_str() + .expect("Failed to parse \"message\" field") + .to_string() } fn parse_client_type(input: &str) -> String { @@ -45,11 +48,11 @@ async fn send_receive_log(udp_socket: Arc, address: SocketAddr, messa Ok(m) => { written += m; debug!("Written {} bytes", m); - } + }, Err(e) => { info!(send_to_error = format!("Write error: {:?}", e)); break; - } + }, } } @@ -59,10 +62,10 @@ async fn send_receive_log(udp_socket: Arc, address: SocketAddr, messa let received_message = String::from_utf8_lossy(&buf[..n]).into_owned(); let address = format!("{}:{}", sender_addr.ip(), sender_addr.port()); info!(received_bytes = n, received_message, address); - } + }, Err(e) => { info!(recv_from_error = format!("Read error: {:?}", e)); - } + }, } } @@ -81,11 +84,11 @@ async fn connect_send_receive_log(udp_socket: Arc, address: SocketAdd Ok(m) => { written += m; debug!("Written {} bytes", m); - } + }, Err(e) => { info!(send_error = format!("Write error: {:?}", e)); break; - } + }, } } @@ -94,10 +97,10 @@ async fn connect_send_receive_log(udp_socket: Arc, address: SocketAdd Ok(n) => { let received_message = String::from_utf8_lossy(&buf[..n]).into_owned(); info!(received_bytes = n, received_message); - } + }, Err(e) => { info!(recv_error = format!("Read error: {:?}", e)); - } + }, } } @@ -111,16 +114,27 @@ impl Scenario for UdpClientLogResponse { fn run(&self, input: &str) -> Result<(), String> { let mut rt = Runtime::from_json(input)?.build(); - let connection_parameters = ConnectionParameters::from_json(input).expect("Failed to parse connection parameters"); + let connection_parameters = + ConnectionParameters::from_json(input).expect("Failed to parse connection parameters"); let message = parse_message(input); let client_type = parse_client_type(input); rt.block_on(async move { let client = Arc::new(create_default_udp_client(connection_parameters.get_address()).await); if client_type == "connected" { - let _ = spawn(connect_send_receive_log(client.clone(), connection_parameters.get_address(), message)).await; + let _ = spawn(connect_send_receive_log( + client.clone(), + connection_parameters.get_address(), + message, + )) + .await; } else if client_type == "unconnected" { - let _ = spawn(send_receive_log(client.clone(), connection_parameters.get_address(), message)).await; + let _ = spawn(send_receive_log( + client.clone(), + connection_parameters.get_address(), + message, + )) + .await; } else { panic!("Client type must be either \"connected\" or \"unconnected\""); } @@ -143,11 +157,11 @@ async fn unconnected_send(udp_socket: Arc, message: String) { Ok(m) => { written += m; debug!("Written {} bytes", m); - } + }, Err(e) => { info!(send_error = format!("Write error: {:?}", e)); break; - } + }, } } } @@ -162,7 +176,8 @@ impl Scenario for UdpClientUnconnectedSendError { fn run(&self, input: &str) -> Result<(), String> { let mut rt = Runtime::from_json(input)?.build(); - let connection_parameters = ConnectionParameters::from_json(input).expect("Failed to parse connection parameters"); + let connection_parameters = + ConnectionParameters::from_json(input).expect("Failed to parse connection parameters"); let message = parse_message(input); let client_type = parse_client_type(input); diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/net/udp/udp_server.rs b/tests/test_scenarios/rust/src/scenarios/runtime/net/udp/udp_server.rs index 70ac131..e8f3b4b 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/net/udp/udp_server.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/net/udp/udp_server.rs @@ -29,17 +29,17 @@ async fn receive_and_echo(udp_socket: Arc) { Ok(m) => { written += m; debug!("Written {} bytes", m); - } + }, Err(e) => { info!("Write error: {:?}", e); break; - } + }, } } - } + }, Err(e) => { info!("Read error: {:?}", e); - } + }, } } @@ -52,7 +52,8 @@ impl Scenario for UdpServerEcho { fn run(&self, input: &str) -> Result<(), String> { let mut rt = Runtime::from_json(input)?.build(); - let connection_parameters = ConnectionParameters::from_json(input).expect("Failed to parse connection parameters"); + let connection_parameters = + ConnectionParameters::from_json(input).expect("Failed to parse connection parameters"); rt.block_on(async move { let listener = Arc::new(create_udp_listener(connection_parameters).await); @@ -76,7 +77,8 @@ impl Scenario for UdpServerLogTTL { fn run(&self, input: &str) -> Result<(), String> { let mut rt = Runtime::from_json(input)?.build(); - let connection_parameters = ConnectionParameters::from_json(input).expect("Failed to parse connection parameters"); + let connection_parameters = + ConnectionParameters::from_json(input).expect("Failed to parse connection parameters"); rt.block_on(async move { let listener = Arc::new(create_udp_listener(connection_parameters).await); diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/sleep/mod.rs b/tests/test_scenarios/rust/src/scenarios/runtime/sleep/mod.rs index ea3bb89..716fb36 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/sleep/mod.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/sleep/mod.rs @@ -15,5 +15,9 @@ mod sleep_basic; use test_scenarios_rust::scenario::{ScenarioGroup, ScenarioGroupImpl}; pub fn sleep_scenario_group() -> Box { - Box::new(ScenarioGroupImpl::new("sleep", vec![Box::new(sleep_basic::SleepBasic)], vec![])) + Box::new(ScenarioGroupImpl::new( + "sleep", + vec![Box::new(sleep_basic::SleepBasic)], + vec![], + )) } diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/worker/dedicated_worker.rs b/tests/test_scenarios/rust/src/scenarios/runtime/worker/dedicated_worker.rs index 4ee7392..81adbb4 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/worker/dedicated_worker.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/worker/dedicated_worker.rs @@ -44,7 +44,7 @@ fn wait_result_str(wait_result: Result<(), String>, wait_time: &Duration) -> &'s } else { "other" } - } + }, } } @@ -53,7 +53,12 @@ fn print_id(id: &str) { info!(id); } -async fn blocking_task(id: String, block_condition: Arc<(Condvar, Mutex)>, notifier: ThreadReadyNotifier, info_fn: fn(&str)) { +async fn blocking_task( + id: String, + block_condition: Arc<(Condvar, Mutex)>, + notifier: ThreadReadyNotifier, + info_fn: fn(&str), +) { let (cv, mtx) = &*block_condition; let mut block = mtx.lock().expect("Unable to lock mutex"); @@ -107,8 +112,14 @@ impl Scenario for OnlyDedicatedWorkers { fn run(&self, input: &str) -> Result<(), String> { let builder = Runtime::from_json(input)?; - let exec_engine = builder.exec_engines().first().expect("No execution engine configuration found"); - let dedicated_workers = exec_engine.dedicated_workers.clone().expect("No dedicated workers configuration found"); + let exec_engine = builder + .exec_engines() + .first() + .expect("No execution engine configuration found"); + let dedicated_workers = exec_engine + .dedicated_workers + .clone() + .expect("No dedicated workers configuration found"); let rt = builder.build(); common_run(rt, dedicated_workers, print_id); @@ -160,8 +171,14 @@ impl Scenario for ThreadPriority { fn run(&self, input: &str) -> Result<(), String> { let builder = Runtime::from_json(input)?; - let exec_engine = builder.exec_engines().first().expect("No execution engine configuration found"); - let dedicated_workers = exec_engine.dedicated_workers.clone().expect("No dedicated workers configuration found"); + let exec_engine = builder + .exec_engines() + .first() + .expect("No execution engine configuration found"); + let dedicated_workers = exec_engine + .dedicated_workers + .clone() + .expect("No dedicated workers configuration found"); let rt = builder.build(); common_run(rt, dedicated_workers, print_id_and_params); @@ -184,8 +201,14 @@ impl Scenario for ThreadAffinity { fn run(&self, input: &str) -> Result<(), String> { let builder = Runtime::from_json(input)?; - let exec_engine = builder.exec_engines().first().expect("No execution engine configuration found"); - let dedicated_workers = exec_engine.dedicated_workers.clone().expect("No dedicated workers configuration found"); + let exec_engine = builder + .exec_engines() + .first() + .expect("No execution engine configuration found"); + let dedicated_workers = exec_engine + .dedicated_workers + .clone() + .expect("No dedicated workers configuration found"); let rt = builder.build(); common_run(rt, dedicated_workers, print_id_and_affinity); @@ -203,8 +226,14 @@ impl Scenario for BlockAllRegularWorkOnDedicated { fn run(&self, input: &str) -> Result<(), String> { let builder = Runtime::from_json(input)?; - let exec_engine = builder.exec_engines().first().expect("No execution engine configuration found"); - let dedicated_workers = exec_engine.dedicated_workers.clone().expect("No dedicated workers configuration found"); + let exec_engine = builder + .exec_engines() + .first() + .expect("No execution engine configuration found"); + let dedicated_workers = exec_engine + .dedicated_workers + .clone() + .expect("No dedicated workers configuration found"); let num_workers = exec_engine.workers; let mut rt = builder.build(); @@ -229,7 +258,12 @@ impl Scenario for BlockAllRegularWorkOnDedicated { let reg_worker_id = format!("worker_{id}"); let notifier = reg_notifiers.pop().expect("Failed to pop notifier"); - joiner.add_handle(spawn(blocking_task(reg_worker_id, reg_block_condition.clone(), notifier, print_id))); + joiner.add_handle(spawn(blocking_task( + reg_worker_id, + reg_block_condition.clone(), + notifier, + print_id, + ))); } // Wait for regular workers to be blocked. @@ -241,7 +275,12 @@ impl Scenario for BlockAllRegularWorkOnDedicated { let unique_worker_id = UniqueWorkerId::from(dedicated_worker.id.as_str()); let notifier = ded_notifiers.pop().expect("Failed to pop notifier"); joiner.add_handle(spawn_on_dedicated( - blocking_task(dedicated_worker.id.clone(), ded_block_condition.clone(), notifier, print_id), + blocking_task( + dedicated_worker.id.clone(), + ded_block_condition.clone(), + notifier, + print_id, + ), unique_worker_id, )); } @@ -270,8 +309,14 @@ impl Scenario for BlockDedicatedWorkOnRegular { fn run(&self, input: &str) -> Result<(), String> { let builder = Runtime::from_json(input)?; - let exec_engine = builder.exec_engines().first().expect("No execution engine configuration found"); - let dedicated_workers = exec_engine.dedicated_workers.clone().expect("No dedicated workers configuration found"); + let exec_engine = builder + .exec_engines() + .first() + .expect("No execution engine configuration found"); + let dedicated_workers = exec_engine + .dedicated_workers + .clone() + .expect("No dedicated workers configuration found"); let num_workers = exec_engine.workers; let mut rt = builder.build(); @@ -296,7 +341,12 @@ impl Scenario for BlockDedicatedWorkOnRegular { let unique_worker_id = UniqueWorkerId::from(dedicated_worker.id.as_str()); let notifier = ded_notifiers.pop().expect("Failed to pop notifier"); joiner.add_handle(spawn_on_dedicated( - blocking_task(dedicated_worker.id.clone(), ded_block_condition.clone(), notifier, print_id), + blocking_task( + dedicated_worker.id.clone(), + ded_block_condition.clone(), + notifier, + print_id, + ), unique_worker_id, )); } @@ -309,7 +359,12 @@ impl Scenario for BlockDedicatedWorkOnRegular { for id in 1..num_workers { let reg_worker_id = format!("worker_{id}"); let notifier = reg_notifiers.pop().expect("Failed to pop notifier"); - joiner.add_handle(spawn(blocking_task(reg_worker_id, reg_block_condition.clone(), notifier, print_id))); + joiner.add_handle(spawn(blocking_task( + reg_worker_id, + reg_block_condition.clone(), + notifier, + print_id, + ))); } // Wait for regular workers to be blocked. @@ -371,9 +426,18 @@ impl Scenario for MultipleTasks { fn run(&self, input: &str) -> Result<(), String> { let builder = Runtime::from_json(input)?; let num_tasks = MultipleTasksTestInput::from_json(input).num_tasks; - let exec_engine = builder.exec_engines().first().expect("No execution engine configuration found").clone(); - let dedicated_workers = exec_engine.dedicated_workers.expect("No dedicated workers configuration found"); - let dedicated_worker = dedicated_workers.first().expect("No dedicated worker configuration found").clone(); + let exec_engine = builder + .exec_engines() + .first() + .expect("No execution engine configuration found") + .clone(); + let dedicated_workers = exec_engine + .dedicated_workers + .expect("No dedicated workers configuration found"); + let dedicated_worker = dedicated_workers + .first() + .expect("No dedicated worker configuration found") + .clone(); let mut rt = builder.build(); rt.block_on(async move { diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/worker/num_workers.rs b/tests/test_scenarios/rust/src/scenarios/runtime/worker/num_workers.rs index 77387f0..00e1cee 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/worker/num_workers.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/worker/num_workers.rs @@ -48,7 +48,10 @@ impl Scenario for NumWorkers { fn run(&self, input: &str) -> Result<(), String> { let builder = Runtime::from_json(input)?; - let exec_engine = builder.exec_engines().first().expect("No execution engine configuration found"); + let exec_engine = builder + .exec_engines() + .first() + .expect("No execution engine configuration found"); let num_workers = exec_engine.workers; let mut rt = builder.build(); @@ -94,7 +97,7 @@ impl Scenario for NumWorkers { } else { info!(wait_result = "other", error = e) } - } + }, } joiner.wait_for_all().await; diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/worker/safety_worker.rs b/tests/test_scenarios/rust/src/scenarios/runtime/worker/safety_worker.rs index 1bec286..e452459 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/worker/safety_worker.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/worker/safety_worker.rs @@ -98,7 +98,11 @@ impl Scenario for SafetyWorkerFailedTaskHandling { async fn outer_task() -> Result<(), String> { info!(name = "outer_task_begin"); let res = safety::spawn(failing_task()).await.expect("Failed to get task result"); - info!(name = "outer_task_end", is_error = res.is_err(), safe_task_handler = true); + info!( + name = "outer_task_end", + is_error = res.is_err(), + safe_task_handler = true + ); res } @@ -218,15 +222,25 @@ async fn successful_task() -> Result<(), String> { async fn nesting_safe_successful_task() -> Result<(), String> { info!(name = "nesting_successful_begin"); - let res = safety::spawn(successful_task()).await.expect("Failed to get task result"); - info!(name = "nesting_successful_end", is_error = res.is_err(), safe_task_handler = true); + let res = safety::spawn(successful_task()) + .await + .expect("Failed to get task result"); + info!( + name = "nesting_successful_end", + is_error = res.is_err(), + safe_task_handler = true + ); res } async fn nesting_safe_failing_task() -> Result<(), String> { info!(name = "nesting_failing_begin"); let res = safety::spawn(failing_task()).await.expect("Failed to get task result"); - info!(name = "nesting_failing_end", is_error = res.is_err(), safe_task_handler = true); + info!( + name = "nesting_failing_end", + is_error = res.is_err(), + safe_task_handler = true + ); res } @@ -351,7 +365,9 @@ impl Scenario for SafetyWorkerSpawnFromReusable { let pool_item = pool.next(failing_task()).expect("Failed to get pool item"); info!(name = "main_begin"); - let res = safety::spawn_from_reusable(pool_item).await.expect("Failed to get task result"); + let res = safety::spawn_from_reusable(pool_item) + .await + .expect("Failed to get task result"); info!(name = "main_end", is_error = res.is_err(), safe_task_handler = true); }); @@ -371,8 +387,14 @@ impl Scenario for SafetyWorkerSpawnOnDedicated { /// fn run(&self, input: &str) -> Result<(), String> { let builder = Runtime::from_json(input)?; - let exec_engine = builder.exec_engines().first().expect("No execution engine configuration found"); - let dedicated_workers = exec_engine.dedicated_workers.clone().expect("No dedicated workers configuration found"); + let exec_engine = builder + .exec_engines() + .first() + .expect("No execution engine configuration found"); + let dedicated_workers = exec_engine + .dedicated_workers + .clone() + .expect("No dedicated workers configuration found"); let mut rt = builder.build(); rt.block_on(async move { @@ -403,8 +425,14 @@ impl Scenario for SafetyWorkerSpawnFromBoxedOnDedicated { /// fn run(&self, input: &str) -> Result<(), String> { let builder = Runtime::from_json(input)?; - let exec_engine = builder.exec_engines().first().expect("No execution engine configuration found"); - let dedicated_workers = exec_engine.dedicated_workers.clone().expect("No dedicated workers configuration found"); + let exec_engine = builder + .exec_engines() + .first() + .expect("No execution engine configuration found"); + let dedicated_workers = exec_engine + .dedicated_workers + .clone() + .expect("No dedicated workers configuration found"); let mut rt = builder.build(); rt.block_on(async move { @@ -435,8 +463,14 @@ impl Scenario for SafetyWorkerSpawnFromReusableOnDedicated { /// fn run(&self, input: &str) -> Result<(), String> { let builder = Runtime::from_json(input)?; - let exec_engine = builder.exec_engines().first().expect("No execution engine configuration found"); - let dedicated_workers = exec_engine.dedicated_workers.clone().expect("No dedicated workers configuration found"); + let exec_engine = builder + .exec_engines() + .first() + .expect("No execution engine configuration found"); + let dedicated_workers = exec_engine + .dedicated_workers + .clone() + .expect("No dedicated workers configuration found"); let mut rt = builder.build(); rt.block_on(async move { diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/worker/spawn_methods.rs b/tests/test_scenarios/rust/src/scenarios/runtime/worker/spawn_methods.rs index 4bb156d..0e645c4 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/worker/spawn_methods.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/worker/spawn_methods.rs @@ -117,11 +117,11 @@ fn create_pool(logic: &ReusableTestInput) -> ReusableBoxFuturePool<()> { "for_type" => { let f = just_log_task("".into()); create_pool_for_type(logic.pool_size, f) - } + }, "for_value" => ReusableBoxFuturePool::for_value(logic.pool_size, just_log_task("".into())), _ => { panic!("Unknown create_method field: {}", logic.create_method); - } + }, } } @@ -159,7 +159,7 @@ impl Scenario for SpawnFromReusable { Ok(pool_item) => pool_items.push(pool_item), Err(error) => { trace_pool_next_error(&error); - } + }, } } @@ -214,10 +214,10 @@ impl Scenario for SpawnFromReusableReuse { match res { Ok(pool_item) => { pool_items.push(pool_item); - } + }, Err(error) => { trace_pool_next_error(&error); - } + }, } } @@ -246,18 +246,29 @@ impl Scenario for SpawnOnDedicated { fn run(&self, input: &str) -> Result<(), String> { let logic = TestInput::new(input); let builder = Runtime::from_json(input)?; - let exec_engine = builder.exec_engines().first().expect("No execution engine configuration found"); - let dedicated_workers = exec_engine.dedicated_workers.clone().expect("No dedicated workers configuration found"); + let exec_engine = builder + .exec_engines() + .first() + .expect("No execution engine configuration found"); + let dedicated_workers = exec_engine + .dedicated_workers + .clone() + .expect("No dedicated workers configuration found"); let mut rt = builder.build(); let mut joiner = RuntimeJoiner::new(); rt.block_on(async move { // Spawn a regular task for thread id comparison - spawn(just_log_task("regular_task".into())).await.expect("spawn() failed unexpectedly"); + spawn(just_log_task("regular_task".into())) + .await + .expect("spawn() failed unexpectedly"); let unique_worker_id = UniqueWorkerId::from(dedicated_workers[0].id.as_str()); for task_ndx in 0..logic.task_count { - joiner.add_handle(spawn_on_dedicated(just_log_task(format!("task_{task_ndx}")), unique_worker_id)); + joiner.add_handle(spawn_on_dedicated( + just_log_task(format!("task_{task_ndx}")), + unique_worker_id, + )); } joiner.wait_for_all().await; @@ -280,14 +291,22 @@ impl Scenario for SpawnFromBoxedOnDedicated { fn run(&self, input: &str) -> Result<(), String> { let logic = TestInput::new(input); let builder = Runtime::from_json(input)?; - let exec_engine = builder.exec_engines().first().expect("No execution engine configuration found"); - let dedicated_workers = exec_engine.dedicated_workers.clone().expect("No dedicated workers configuration found"); + let exec_engine = builder + .exec_engines() + .first() + .expect("No execution engine configuration found"); + let dedicated_workers = exec_engine + .dedicated_workers + .clone() + .expect("No dedicated workers configuration found"); let mut rt = builder.build(); let mut joiner = RuntimeJoiner::new(); rt.block_on(async move { // Spawn a regular task for thread id comparison - spawn(just_log_task("regular_task".into())).await.expect("spawn() failed unexpectedly"); + spawn(just_log_task("regular_task".into())) + .await + .expect("spawn() failed unexpectedly"); let unique_worker_id = UniqueWorkerId::from(dedicated_workers[0].id.as_str()); for task_ndx in 0..logic.task_count { @@ -319,7 +338,9 @@ impl Scenario for SpawnFromBoxedOnDedicatedInvalidWorker { rt.block_on(async move { let invalid_worker_id = UniqueWorkerId::from("invalid_worker"); - let _ = spawn_from_boxed_on_dedicated(box_future(just_log_task("dedicated_task".into())), invalid_worker_id).await; + let _ = + spawn_from_boxed_on_dedicated(box_future(just_log_task("dedicated_task".into())), invalid_worker_id) + .await; }); Ok(()) @@ -338,8 +359,14 @@ impl Scenario for SpawnFromReusableOnDedicated { fn run(&self, input: &str) -> Result<(), String> { let logic = ReusableTestInput::new(input); let builder = Runtime::from_json(input)?; - let exec_engine = builder.exec_engines().first().expect("No execution engine configuration found"); - let dedicated_workers = exec_engine.dedicated_workers.clone().expect("No dedicated workers configuration found"); + let exec_engine = builder + .exec_engines() + .first() + .expect("No execution engine configuration found"); + let dedicated_workers = exec_engine + .dedicated_workers + .clone() + .expect("No dedicated workers configuration found"); let mut rt = builder.build(); let mut joiner = RuntimeJoiner::new(); @@ -353,15 +380,17 @@ impl Scenario for SpawnFromReusableOnDedicated { match res { Ok(pool_item) => { pool_items.push(pool_item); - } + }, Err(error) => { trace_pool_next_error(&error); - } + }, } } // Spawn a regular task for thread id comparison - spawn(just_log_task("regular_task".into())).await.expect("spawn() failed unexpectedly"); + spawn(just_log_task("regular_task".into())) + .await + .expect("spawn() failed unexpectedly"); for pool_item in pool_items { joiner.add_handle(spawn_from_reusable_on_dedicated(pool_item, unique_worker_id)); } @@ -386,8 +415,14 @@ impl Scenario for SpawnFromReusableOnDedicatedReuse { fn run(&self, input: &str) -> Result<(), String> { let logic = ReusableReuseTestInput::new(input); let builder = Runtime::from_json(input)?; - let exec_engine = builder.exec_engines().first().expect("No execution engine configuration found"); - let dedicated_workers = exec_engine.dedicated_workers.clone().expect("No dedicated workers configuration found"); + let exec_engine = builder + .exec_engines() + .first() + .expect("No execution engine configuration found"); + let dedicated_workers = exec_engine + .dedicated_workers + .clone() + .expect("No dedicated workers configuration found"); let mut rt = builder.build(); rt.block_on(async move { @@ -403,15 +438,17 @@ impl Scenario for SpawnFromReusableOnDedicatedReuse { match res { Ok(pool_item) => { pool_items.push(pool_item); - } + }, Err(error) => { trace_pool_next_error(&error); - } + }, } } // Spawn a regular task for thread id comparison - spawn(just_log_task("regular_task".into())).await.expect("spawn() failed unexpectedly"); + spawn(just_log_task("regular_task".into())) + .await + .expect("spawn() failed unexpectedly"); for pool_item in pool_items { joiner.add_handle(spawn_from_reusable_on_dedicated(pool_item, unique_worker_id)); } @@ -440,7 +477,9 @@ impl Scenario for SpawnFromReusableOnDedicatedInvalidWorker { rt.block_on(async move { let mut pool = ReusableBoxFuturePool::for_value(logic.pool_size, just_log_task("".into())); - let pool_item = pool.next(just_log_task("dedicated_task".into())).expect("Failed to get pool item"); + let pool_item = pool + .next(just_log_task("dedicated_task".into())) + .expect("Failed to get pool item"); let invalid_worker_id = UniqueWorkerId::from("invalid_worker"); let _ = spawn_from_reusable_on_dedicated(pool_item, invalid_worker_id).await; diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/worker/thread_affinity.rs b/tests/test_scenarios/rust/src/scenarios/runtime/worker/thread_affinity.rs index 815d271..b928406 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/worker/thread_affinity.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/worker/thread_affinity.rs @@ -51,7 +51,10 @@ impl Scenario for ThreadAffinity { fn run(&self, input: &str) -> Result<(), String> { let builder = Runtime::from_json(input)?; - let exec_engine = builder.exec_engines().first().expect("No execution engine configuration found"); + let exec_engine = builder + .exec_engines() + .first() + .expect("No execution engine configuration found"); let num_workers = exec_engine.workers; let mut rt = builder.build(); diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/worker/thread_priority.rs b/tests/test_scenarios/rust/src/scenarios/runtime/worker/thread_priority.rs index 25f2984..314b842 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/worker/thread_priority.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/worker/thread_priority.rs @@ -56,7 +56,10 @@ impl Scenario for ThreadPriority { fn run(&self, input: &str) -> Result<(), String> { let builder = Runtime::from_json(input)?; - let exec_engine = builder.exec_engines().first().expect("No execution engine configuration found"); + let exec_engine = builder + .exec_engines() + .first() + .expect("No execution engine configuration found"); let num_workers = exec_engine.workers; let mut rt = builder.build(); diff --git a/tests/test_scenarios/rust/src/scenarios/runtime/worker/worker_with_blocking_tasks.rs b/tests/test_scenarios/rust/src/scenarios/runtime/worker/worker_with_blocking_tasks.rs index aacbe9b..b031bd0 100644 --- a/tests/test_scenarios/rust/src/scenarios/runtime/worker/worker_with_blocking_tasks.rs +++ b/tests/test_scenarios/rust/src/scenarios/runtime/worker/worker_with_blocking_tasks.rs @@ -52,7 +52,12 @@ async fn non_blocking_task(name: String, counter: Arc) { counter.fetch_add(1, Ordering::Release); } -async fn blocking_task(name: String, counter: Arc, counter_unblock_value: usize, notifier: ThreadReadyNotifier) { +async fn blocking_task( + name: String, + counter: Arc, + counter_unblock_value: usize, + notifier: ThreadReadyNotifier, +) { location_checkpoint(name.as_str(), "begin"); counter.fetch_add(1, Ordering::Release); notifier.ready(); @@ -84,9 +89,16 @@ impl Scenario for WorkerWithBlockingTasks { let all_tasks_count: usize = logic.blocking_tasks.len() + logic.non_blocking_tasks.len(); for name in logic.blocking_tasks.as_slice() { let notifier = mid_notifiers.pop().expect("Failed to pop notifier"); - joiner.add_handle(spawn(blocking_task(name.to_string(), counter.clone(), all_tasks_count, notifier))); + joiner.add_handle(spawn(blocking_task( + name.to_string(), + counter.clone(), + all_tasks_count, + notifier, + ))); } - mid_barrier.wait_for_notification(Duration::from_secs(5)).expect("Failed to join tasks"); + mid_barrier + .wait_for_notification(Duration::from_secs(5)) + .expect("Failed to join tasks"); for name in logic.non_blocking_tasks.as_slice() { joiner.add_handle(spawn(non_blocking_task(name.to_string(), counter.clone()))); From 9f6e81bbb11b336607dc8637121d80250de218c5 Mon Sep 17 00:00:00 2001 From: Piotr Korkus Date: Mon, 9 Feb 2026 12:27:37 +0100 Subject: [PATCH 3/3] bazel: bump deps --- .bazelrc | 37 +++++++++++++++++++++--- .github/workflows/build_qnx8.yml | 4 +-- MODULE.bazel | 49 ++++++++++++++++---------------- README.md | 27 +++++++++--------- rust-toolchain.toml | 2 +- rustfmt.toml | 1 + 6 files changed, 76 insertions(+), 44 deletions(-) diff --git a/.bazelrc b/.bazelrc index 310e991..8127f9e 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,3 +1,26 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +# ------------------------------------------------------------------------------- +# Links to S-CORE Bazel registry and Bazel Central Registry +# ------------------------------------------------------------------------------- +common --registry=https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/ +common --registry=https://bcr.bazel.build +common --credential_helper=*.qnx.com=%workspace%/scripts/internal/qnx_creds.py + +# ------------------------------------------------------------------------------- +# Default flags (all configurations) +# ------------------------------------------------------------------------------- build --java_language_version=17 build --tool_java_language_version=17 build --java_runtime_version=remotejdk_17 @@ -5,18 +28,21 @@ build --tool_java_runtime_version=remotejdk_17 test --test_output=errors -common --registry=https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/ -common --registry=https://bcr.bazel.build -common --credential_helper=*.qnx.com=%workspace%/scripts/internal/qnx_creds.py - # Ferrocene must be common compiler for HOST. To ensure metadata compatibility for proc macro crates! build:_common --extra_toolchains=@score_toolchains_rust//toolchains/ferrocene:ferrocene_x86_64_unknown_linux_gnu + +# ------------------------------------------------------------------------------- +# Config dedicated to target platform CPU:arm64 and OS:QNX +# ------------------------------------------------------------------------------- build:arm64-qnx --config=_common build:arm64-qnx --platforms=@score_bazel_platforms//:aarch64-qnx-sdp_8.0.0-posix build:arm64-qnx --extra_toolchains=@score_qcc_aarch64_toolchain//:aarch64-qnx-sdp_8.0.0-posix build:arm64-qnx --extra_toolchains=@score_toolchains_rust//toolchains/ferrocene:ferrocene_aarch64_unknown_nto_qnx800 +# ------------------------------------------------------------------------------- +# Config dedicated to target platform CPU:x86_64 and OS:QNX +# ------------------------------------------------------------------------------- build:x86_64-qnx --config=_common build:x86_64-qnx --platforms=@score_bazel_platforms//:x86_64-qnx-sdp_8.0.0-posix build:x86_64-qnx --extra_toolchains=@score_qcc_x86_64_toolchain//:x86_64-qnx-sdp_8.0.0-posix @@ -24,6 +50,9 @@ build:x86_64-qnx --extra_toolchains=@score_toolchains_rust//toolchains/ferrocene # TODO arm64 when rust support is there +# ------------------------------------------------------------------------------- +# Config dedicated to host platform CPU:x86_64 and OS:Linux +# ------------------------------------------------------------------------------- build:x86_64-linux --config=_common build:x86_64-linux --platforms=@score_bazel_platforms//:x86_64-linux-gcc_12.2.0-posix build:x86_64-linux --extra_toolchains=@score_gcc_x86_64_toolchain//:x86_64-linux-gcc_12.2.0-posix diff --git a/.github/workflows/build_qnx8.yml b/.github/workflows/build_qnx8.yml index 66b578c..224e994 100644 --- a/.github/workflows/build_qnx8.yml +++ b/.github/workflows/build_qnx8.yml @@ -25,7 +25,7 @@ jobs: pull-requests: read with: bazel-target: '//src/...' - bazel-config: 'arm64-qnx8' + bazel-config: 'arm64-qnx' credential-helper: 'scripts/internal/qnx_creds.py' environment-name: 'workflow-approval' secrets: @@ -39,7 +39,7 @@ jobs: pull-requests: read with: bazel-target: '//src/...' - bazel-config: 'x86_64-qnx8' + bazel-config: 'x86_64-qnx' credential-helper: 'scripts/internal/qnx_creds.py' environment-name: 'workflow-approval' secrets: diff --git a/MODULE.bazel b/MODULE.bazel index 7495676..8280ed2 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -33,41 +33,25 @@ bazel_dep(name = "platforms", version = "1.0.0") # S-CORE process rules bazel_dep(name = "score_bazel_platforms", version = "0.0.4") -bazel_dep(name = "score_docs_as_code", version = "2.2.0") +bazel_dep(name = "score_docs_as_code", version = "3.0.0") bazel_dep(name = "score_tooling", version = "1.1.0") bazel_dep(name = "score_rust_policies", version = "0.0.3") -bazel_dep(name = "score_process", version = "1.2.1", dev_dependency = True) -bazel_dep(name = "score_platform", version = "0.4.2", dev_dependency = True) # This is main score repo -bazel_dep(name = "score_virtualization", version = "0.0.1", dev_dependency = True) +bazel_dep(name = "score_process", version = "1.4.3", dev_dependency = True) +bazel_dep(name = "score_platform", version = "0.5.2", dev_dependency = True) # This is main score repo +git_override( + module_name = "score_platform", + commit = "6ef2b8c740eb538d9b9b44fabd3dea5e0a888da6", + remote = "https://github.com/qorix-group/score.git", +) # Toolchains and extensions bazel_dep(name = "score_bazel_cpp_toolchains", version = "0.2.2", dev_dependency = True) bazel_dep(name = "score_toolchains_rust", version = "0.4.0", dev_dependency = True) # Others -bazel_dep(name = "custom_qemu", version = "1.0.0", dev_dependency = True) - -bazel_dep(name = "googletest", version = "1.14.0") - bazel_dep(name = "score_test_scenarios", version = "0.3.1", dev_dependency = True) -# Overrides -git_override( - module_name = "score_virtualization", - commit = "99d3f153c43796b67a63e82aad1ede6a881aa6af", - remote = "https://github.com/qorix-group/score_virtualization.git", -) - -archive_override( - module_name = "custom_qemu", - integrity = "sha256-3V2d+p7nP0tsbrVWOPYUSJogLNal43CIAHEto6Vjdfg=", - strip_prefix = "third_party", # matches top-level dir in the tar - urls = [ - "https://github.com/qorix-group/custom-qemu/releases/download/1.0.0/custom_qemu.tar.gz", - ], -) - gcc = use_extension("@score_bazel_cpp_toolchains//extensions:gcc.bzl", "gcc", dev_dependency = True) gcc.toolchain( name = "score_gcc_x86_64_toolchain", @@ -126,5 +110,22 @@ use_repo(python) use_repo(pip, "pip_score_venv_test") +bazel_dep(name = "score_virtualization", version = "0.0.3", dev_dependency = True) +git_override( + module_name = "score_virtualization", + commit = "99d3f153c43796b67a63e82aad1ede6a881aa6af", + remote = "https://github.com/qorix-group/score_virtualization.git", +) + +bazel_dep(name = "custom_qemu", version = "1.0.0", dev_dependency = True) +archive_override( + module_name = "custom_qemu", + integrity = "sha256-3V2d+p7nP0tsbrVWOPYUSJogLNal43CIAHEto6Vjdfg=", + strip_prefix = "third_party", # matches top-level dir in the tar + urls = [ + "https://github.com/qorix-group/custom-qemu/releases/download/1.0.0/custom_qemu.tar.gz", + ], +) + # S-CORE crates bazel_dep(name = "score_crates", version = "0.0.7") diff --git a/README.md b/README.md index 862b714..866e0d4 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,6 @@ Repository for **safe async runtime** called **kyron** for Rust [![Nightly CIT (Bazel)](../../actions/workflows/component_integration_tests_bazel.yml/badge.svg)](../../actions/workflows/component_integration_tests_bazel.yml) [![Kyron Examples](https://img.shields.io/badge/Kyron-examples-red?style=flat&link=https%3A%2F%2Fgithub.com%2Feclipse-score%kyron%2Ftree%2Fmain%2Fsrc%2Fkyron)](src/kyron/README.md) - - ## Feature status and roadmap * [Async Runtime](src/kyron/doc/features.md) @@ -17,19 +15,21 @@ Repository for **safe async runtime** called **kyron** for Rust This repository includes two GitHub Actions workflows for component integration testing: ### Component Integration Tests (Cargo-based) -- **Schedule**: Runs nightly at 1:45 UTC -- **Build System**: Uses Cargo for Rust components -- **Testing**: Executes Python test suite with pytest -- **Nightly Mode**: Runs tests 20 times with `--count 20 --repeat-scope session` for enhanced + +* **Schedule**: Runs nightly at 1:45 UTC +* **Build System**: Uses Cargo for Rust components +* **Testing**: Executes Python test suite with pytest +* **Nightly Mode**: Runs tests 20 times with `--count 20 --repeat-scope session` for enhanced reliability testing -- **Triggers**: Push/PR to main/development branches, and scheduled nightly runs +* **Triggers**: Push/PR to main/development branches, and scheduled nightly runs ### Component Integration Tests (Bazel-based) -- **Schedule**: Runs nightly at 1:15 UTC -- **Build System**: Uses Bazel for all components -- **Testing**: Builds Rust test scenarios and runs Python component integration tests -- **Nightly Mode**: Uses `cit_repeat` target for flake detection -- **Triggers**: Push/PR to main/development branches, and scheduled nightly runs + +* **Schedule**: Runs nightly at 1:15 UTC +* **Build System**: Uses Bazel for all components +* **Testing**: Builds Rust test scenarios and runs Python component integration tests +* **Nightly Mode**: Uses `cit_repeat` target for flake detection +* **Triggers**: Push/PR to main/development branches, and scheduled nightly runs Monitor via the status badges above and the Actions tab @@ -40,6 +40,7 @@ Monitor via the status badges above and the Actions tab ```bash sudo apt-get update sudo apt-get install -y curl build-essential protobuf-compiler libclang-dev git python3-dev python-is-python3 python3-venv +sudo apt install libc++-dev libc++abi-dev libstdc++-dev g++ ``` ### Rust installation @@ -91,8 +92,8 @@ Please follow to get access to QNX8 and how to setup QNX8 for `S-CORE`. In above link You will also find an instructions how to replace SDP in case You need to use other one (ie HW specific). - ### Building + ```bash ./scripts/build_qnx8.sh BAZEL_TARGET (default is //src/...) ``` diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 552d6d6..ff100ed 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.85.0" \ No newline at end of file +channel = "1.90.0" diff --git a/rustfmt.toml b/rustfmt.toml index 40aad1c..5feedae 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,6 +1,7 @@ # rust formatter rules. # check configuration fields here: https://rust-lang.github.io/rustfmt/?version=v1.6.0&search= +# We need to support `cargo fmt` for crates.io edition = "2021" tab_spaces = 4 match_block_trailing_comma = true