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

Can Controller be Send and Sync? #6

Open
adeschamps opened this issue Nov 5, 2018 · 1 comment
Open

Can Controller be Send and Sync? #6

adeschamps opened this issue Nov 5, 2018 · 1 comment

Comments

@adeschamps
Copy link
Contributor

I think we can implement Send and Sync for Controller, but I'd like someone else to weigh in before I submit a PR. Send and Sync are not implemented automatically because Controller contains raw pointers.

I believe they are safe to implement because nothing in the Controller API gives access to its internal ws_2811_t C struct. Since it is the only thing that can access it, there is no possibility of pointer aliasing.

My use case is that I would like to initialize Controller and then create a thread that accepts messages via a channel and changes lights. Without implementing Send, I would have to initialize Controller inside this thread, which means I can't handle initialization errors before spinning up the thread.

@JMurph2015
Copy link
Collaborator

Sorry for the late reply, but college finals just finished up so I'm finally able to spend some time programming fun things.

Basically, I'm not sure it can implement either safely due to the wrapping of the ws2811_t structs from the core library. It's not clear that either are valid assumptions about the memory managed by rpi_ws281x, and unfortunately since this library directly wraps an object managed by rpi_ws281x, we can't be sure without inspecting the C library, which will be some non-trivial amount of effort.

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

No branches or pull requests

2 participants