-
Notifications
You must be signed in to change notification settings - Fork 123
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
Is the framework threadsafe? #454
Comments
Hi, sorry for the long delay. |
Hi, |
Also, the UI is modified on the queue given in the |
I scanned the framework layers and only potential concern is
where code grabs an array index in one sync call and uses it in a 2nd. Great to see all the code improvements over past year. We defaulted to always mutate MeshNetworkManager from main thread following convention in Example App. One downside is there is a lot of main thread processing when saving. I don't think access to this class can be moved to another thread (at least yet). Issue title may be missleading since it is a shared assumption between Example App and framework that any mutation occurs on main thread. No problem if you want to close this issue and track any remaining efforts differently. |
I will release the lib as is now and will look into that later. And let's leave it open not to forget. Thanks for the feedback! Hope you don't have problems migrating to the latest changes. |
Is the nRFProvision framework threadsafe? It appears writes to the
MeshNetwork
class all occur from themain thread (mostly done by view controllers, see below), however reads also occur from the background threadpool threads that serve
NetworkManager
and it's "meshstack" layers.E.g. the
UpperTransportPDU.decode()
method accesses themeshnetwork.groups
,meshnetwork.applicationkeys
andmeshnetwork.nodes
arrays. Is this a correct understanding, or is there some other closure capture mechansism in play that mitigates this when work is run from the background dispatch queue?I see the data structures internal to the layers (e.g.
UpperTransportLayer.queues
) are properly protected by a lock. It appears with the Example App UI the probabiliity for memory access conflicts is low, due to time it takes for a user to navigate views, although it could happen if sending e.g. Config msgs to a node several hops away, or if a 2nd Provisioner client is also configuring a different node.I am aware of the
MeshNetworkManager.instance()
method that switches to main thread before accessing meshnetwork. The model delegates use this mechanism when accessingmeshnetwork
object and processing received msgs. The viewcontrollers also access through this method, but threafter appear to make assumption it is on main thread. Is it possible to redefine.instance()
so that it instead accessesmeshnetwork
objects on a custom thread pool (and modifying UI accordingly, or accept frequent GCD priority inversion when accessed from main thread)?The text was updated successfully, but these errors were encountered: