-
Notifications
You must be signed in to change notification settings - Fork 22
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 SEXP
both Send
and Sync
#202
Comments
Rustonomicon says:
|
Yes. But that's for rust types. Types that inherently contain information on whether they are Sync or Send. So you can stipulate with the abstractions mentioned above, what can happen to them. But SEXP are with no type information. Either we allow them to be used as primitives, that then the higher level api can dress however it see fits, or this wrapping will happen in every other higher end library. This eases the syntax burden upstream. Like you wouldn't need to use usize in ownership module. I can be persuaded that this is a bad idea though, I just want to communicate this opinion. |
I might be wrong, but, in my understanding, pointers are not Sync or Send simply because there's no mechanism to prevent data race or access conflict. For example, it's possible you access to an SEXP and it's already GC-ed on another thread.
Yeah, I get your point that marking SEXP as Send and Sync is less bad than treating it as usize. But, I think it should be done rather on extendr's side by wrapping it with a new type if needed. |
Thank you. I'd like to discuss this some more. I'm still myself not convinced of either direction. Plus where types are defined, in this case The GC example you mention is interesting. There is only one R-session active. So in a multi-threaded setting, A But in any of these cases, you'd be sending So in both implementations, you'd need SEXP to be I'd also emphasize that While that's said, I still don't want this to be forced in, without extensive discussions. The PRs I've made is to explore these ideas. SIDE NOTEJust another completely different thing, since SEXPREC is an opaque type, maybe what we should be doing is this: https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs ? |
By way of extendr/extendr#659, I think we should make
SEXP
a wrapper aroundSEXP
, and defineSend
andSync
for this. It is a pointer, and I see no qualms with making it passable to threads. A higher-level abstraction likeRobj
should ensure thatSend
/Sync
makes sense, through various means (likeBox
,Mutex
,single_threaded
,ownership
, etc.).The text was updated successfully, but these errors were encountered: