Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make async mqtt client implement Send #461

Merged
merged 1 commit into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/private/unblocker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ where
task: TaskHandle_t,
}

/// SAFETY: Unblocker uses a raw pointer in Unblocker::task. This causes rust to treat it as not Send.
/// However, this task handle is only ever used to delete the FreeRTOS task, which is safe to do from any thread.
unsafe impl<T: Send + 'static> Send for Unblocker<T> {}

impl<T> Unblocker<T>
where
T: Send + 'static,
Expand Down
6 changes: 3 additions & 3 deletions src/private/zerocopy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ where
}
}

unsafe impl<T> Send for Receiver<T> where T: Send + 'static {}
unsafe impl<'a, T> Send for Receiver<T> where T: Send + 'a {}
ivmarkov marked this conversation as resolved.
Show resolved Hide resolved

pub struct QuitOnDrop<T>(Arc<Channel<T>>)
where
Expand Down Expand Up @@ -182,8 +182,8 @@ where
}
}

unsafe impl<T> Send for Channel<T> where T: Send + 'static {}
unsafe impl<T> Sync for Channel<T> where T: Send + 'static {}
unsafe impl<'a, T> Send for Channel<T> where T: Send + 'a {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto.

unsafe impl<'a, T> Sync for Channel<T> where T: Send + 'a {}
ivmarkov marked this conversation as resolved.
Show resolved Hide resolved

#[derive(Copy, Clone, Debug)]
enum State<T> {
Expand Down
Loading