Skip to content

Commit

Permalink
refactor(threads): sync submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
elenaf9 committed Oct 2, 2024
1 parent 4e47adb commit 7025ad6
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions examples/core-sizes/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use riot_rs::debug::{exit, log::*, EXIT_SUCCESS};
#[riot_rs::thread(autostart)]
fn main() {
info!(
"riot_rs::thread::lock::Lock: {}",
core::mem::size_of::<riot_rs::thread::lock::Lock>(),
"riot_rs::thread::sync::Lock: {}",
core::mem::size_of::<riot_rs::thread::sync::Lock>(),
);
info!(
"riot_rs::thread::Thread: {}",
Expand Down
2 changes: 1 addition & 1 deletion examples/threading-channel/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#![feature(used_with_arg)]

use riot_rs::debug::log::*;
use riot_rs::thread::channel::Channel;
use riot_rs::thread::sync::Channel;

static CHANNEL: Channel<u8> = Channel::new();

Expand Down
7 changes: 3 additions & 4 deletions src/riot-rs-threads/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
//! # Synchronization
//!
//! The `threading` module supports three basic synchronization primitives:
//! - [`Channel`](channel::Channel): synchronous (blocking) channel for sending data between threads
//! - [`Lock`](lock::Lock): basic locking object
//! - [`Channel`](sync::Channel): synchronous (blocking) channel for sending data between threads
//! - [`Lock`](sync::Lock): basic locking object
//! - [`thread_flags`]: thread-flag implementation for signaling between threads

#![cfg_attr(not(test), no_std)]
Expand All @@ -35,8 +35,7 @@ mod ensure_once;
mod thread;
mod threadlist;

pub mod channel;
pub mod lock;
pub mod sync;
pub mod thread_flags;

#[doc(hidden)]
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
//! This module provides a Lock implementation.
use core::cell::UnsafeCell;

use super::threadlist::ThreadList;
use super::ThreadState;
use crate::{threadlist::ThreadList, ThreadState};

/// A basic locking object.
///
Expand Down
6 changes: 6 additions & 0 deletions src/riot-rs-threads/src/sync/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//! Synchronization primitives.
mod channel;
mod lock;

pub use channel::Channel;
pub use lock::Lock;
4 changes: 2 additions & 2 deletions src/riot-rs-threads/src/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ pub enum ThreadState {
LockBlocked,
/// Waiting for [`ThreadFlags`] to be set.
FlagBlocked(crate::thread_flags::WaitMode),
/// Waiting to receive on a [`super::channel::Channel`], i.e. waiting for the sender.
/// Waiting to receive on a [`crate::sync::Channel`], i.e. waiting for the sender.
ChannelRxBlocked(usize),
/// Waiting to send on a [`super::channel::Channel`], i.e. waiting for the receiver.
/// Waiting to send on a [`crate::sync::Channel`], i.e. waiting for the receiver.
ChannelTxBlocked(usize),
}

Expand Down
2 changes: 1 addition & 1 deletion tests/threading-lock/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#![feature(used_with_arg)]

use portable_atomic::{AtomicUsize, Ordering};
use riot_rs::thread::{lock::Lock, thread_flags, ThreadId};
use riot_rs::thread::{sync::Lock, thread_flags, ThreadId};

static LOCK: Lock = Lock::new();
static RUN_ORDER: AtomicUsize = AtomicUsize::new(0);
Expand Down

0 comments on commit 7025ad6

Please sign in to comment.