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

Implement Send + Sync on BorrowedMessage #190

Merged
merged 1 commit into from
Dec 9, 2019

Conversation

benesch
Copy link
Collaborator

@benesch benesch commented Dec 9, 2019

librdkafka is entirely thread safe, and guarantees that the memory
referenced by a BorrowedMessage will remain valid as long as the
consumer remains valid. Since BorrowedMessage has a reference to the
consumer inside, Rust will enforce this invariant, and it is therefore
safe to mark BorrowedMessage as Send + Sync.

Also update the asynchronous_processing example to make use of this new
feature. The example now allows spawning multiple workers, which
requires tokio::spawn, which turn requires that the generated future
implement Send, which finally requires the adjustment made in this
patch.

Fix #85.
Fix #189.

librdkafka is entirely thread safe, and guarantees that the memory
referenced by a BorrowedMessage will remain valid as long as the
consumer remains valid. Since BorrowedMessage has a reference to the
consumer inside, Rust will enforce this invariant, and it is therefore
safe to mark BorrowedMessage as Send + Sync.

Also update the asynchronous_processing example to make use of this new
feature. The example now allows spawning multiple workers, which
requires tokio::spawn, which turn requires that the generated future
implement Send, which finally requires the adjustment made in this
patch.

Fix fede1024#85.
Fix fede1024#189.
@benesch benesch merged commit d159783 into fede1024:master Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BorrowedMessage should be Send, maybe Sync. Running StreamConsumer with tokio's executor
1 participant