solana-program-library
solana-program-library copied to clipboard
`Token` type is `!Send + !Sync`
The Token type in token/client/src/token.rs seems to have been designed in order to be Send + Sync, given the fact that Arc was used for the different fields. However, marker traits Send + Sync are not added to the traits objects and as such fails Token fails to capture this feature.
I'm willing to implement this if the issue is accepted.
Hey there, are you talking about right here?
https://github.com/solana-labs/solana-program-library/blob/ce0389be112bed8da01dd0fc3088204a62408cbc/token/client/src/token.rs#L383-L386
And could you maybe elaborate on what the motivation would be to add this change? It's not immediately clear from the description.
Thanks!
hey @buffalojoec, I was talking about the type below. From what I can see from the fields, it seems like the type was made in order to be Send + Sync? Otherwise why use Arc for client, payer,... ? I think we could make Token thread-safe by adding Send + Sync as a bounds for client, payer and nonce_authority.
https://github.com/solana-labs/solana-program-library/blob/ce0389be112bed8da01dd0fc3088204a62408cbc/token/client/src/token.rs#L331-L342
@greged93 Sorry I'm just getting back here!
Yeah I think making Token thread-safe makes sense. If you think it's important go for it!
Great! Can you assign the issue?
Why can't we directly send Token between threads? I think this is necessary to fully utilize multithreading
If ProgramClient cannot be sent or synchronized directly between threads, how should it be handled in concurrent scenarios? I believe it needs to be implemented with the Send and Sync traits to address multithreading concurrency issues.