Skip to content

How to run struct function in tokio spawn? #4426

Answered by Darksonn
fy2462 asked this question in Q&A
Discussion options

You must be logged in to vote

The type you are creating with the shared self is an Arc<&Self>, which has a reference inside it, but to use an Arc, the struct must go inside the Arc without an ampersand.

Check out this article for a description of how to accomplish this kind of thing. The general idea in the article is to split your struct into two structs so that you don't need to share it in the first place.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@fy2462
Comment options

Answer selected by fy2462
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants