Small tidy up
This commit is contained in:
parent
d711e8a82c
commit
076198a3b9
1 changed files with 10 additions and 10 deletions
|
@ -563,7 +563,7 @@ pub struct Channel<M, T, const N: usize>
|
||||||
where
|
where
|
||||||
M: Mutex<Data = ()>,
|
M: Mutex<Data = ()>,
|
||||||
{
|
{
|
||||||
sync_channel: UnsafeCell<ChannelCell<M, T, N>>,
|
channel_cell: UnsafeCell<ChannelCell<M, T, N>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ChannelCell<M, T, const N: usize>
|
struct ChannelCell<M, T, const N: usize>
|
||||||
|
@ -593,9 +593,9 @@ impl<T, const N: usize> Channel<WithCriticalSections, T, N> {
|
||||||
pub const fn with_critical_sections() -> Self {
|
pub const fn with_critical_sections() -> Self {
|
||||||
let mutex = CriticalSectionMutex::new(());
|
let mutex = CriticalSectionMutex::new(());
|
||||||
let state = ChannelState::new();
|
let state = ChannelState::new();
|
||||||
let sync_channel = ChannelCell { mutex, state };
|
let channel_cell = ChannelCell { mutex, state };
|
||||||
Channel {
|
Channel {
|
||||||
sync_channel: UnsafeCell::new(sync_channel),
|
channel_cell: UnsafeCell::new(channel_cell),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -620,9 +620,9 @@ impl<T, const N: usize> Channel<WithThreadModeOnly, T, N> {
|
||||||
pub const fn with_thread_mode_only() -> Self {
|
pub const fn with_thread_mode_only() -> Self {
|
||||||
let mutex = ThreadModeMutex::new(());
|
let mutex = ThreadModeMutex::new(());
|
||||||
let state = ChannelState::new();
|
let state = ChannelState::new();
|
||||||
let sync_channel = ChannelCell { mutex, state };
|
let channel_cell = ChannelCell { mutex, state };
|
||||||
Channel {
|
Channel {
|
||||||
sync_channel: UnsafeCell::new(sync_channel),
|
channel_cell: UnsafeCell::new(channel_cell),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -644,9 +644,9 @@ impl<T, const N: usize> Channel<WithNoThreads, T, N> {
|
||||||
pub const fn with_no_threads() -> Self {
|
pub const fn with_no_threads() -> Self {
|
||||||
let mutex = NoopMutex::new(());
|
let mutex = NoopMutex::new(());
|
||||||
let state = ChannelState::new();
|
let state = ChannelState::new();
|
||||||
let sync_channel = ChannelCell { mutex, state };
|
let channel_cell = ChannelCell { mutex, state };
|
||||||
Channel {
|
Channel {
|
||||||
sync_channel: UnsafeCell::new(sync_channel),
|
channel_cell: UnsafeCell::new(channel_cell),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -657,9 +657,9 @@ where
|
||||||
{
|
{
|
||||||
fn lock<R>(&self, f: impl FnOnce(&mut ChannelState<T, N>) -> R) -> R {
|
fn lock<R>(&self, f: impl FnOnce(&mut ChannelState<T, N>) -> R) -> R {
|
||||||
unsafe {
|
unsafe {
|
||||||
let sync_channel = &mut *(self.sync_channel.get());
|
let channel_cell = &mut *(self.channel_cell.get());
|
||||||
let mutex = &mut sync_channel.mutex;
|
let mutex = &mut channel_cell.mutex;
|
||||||
let mut state = &mut sync_channel.state;
|
let mut state = &mut channel_cell.state;
|
||||||
mutex.lock(|_| f(&mut state))
|
mutex.lock(|_| f(&mut state))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue