I can't find any locking mechanism in Wolfram documentation for independent concurrent processes, which is needed for Cloud-based synchronization. The only ones I can find are for parallel processing in a system with cooperating kernels.

I have CloudObjects which need to be modifiable from different devices. This means managing access among independently running Cloud processes. These objects are designed so that read-only access is permissible from anywhere at anytime, but only one process can have write access at a time.

I would like to maintain a Cloud-based global variable/file to control write access, but neither WithLock nor CriticalSection will allow a CloudObject for locking, so I don't see how to create an atomic read-test-set operation on my control variable.

Is there an alternate mechanism available, or did I miss something in my attempts to use a CloudObject with either WithLock or CriticalSection?

  • $\begingroup$ Perhaps you could use a global queue to force the serialization of all updates? $\endgroup$ Jun 7, 2022 at 21:57
  • $\begingroup$ Thank you for the suggestion, @RohitNamjoshi, but serializing does not solve my problem. Also, managing read/write access to a queue has the same issue as managing read/write access to a Cloud state variable. I have edited my post to provide more detail about my needs. $\endgroup$
    – G. Shults
    Jun 9, 2022 at 20:24
  • $\begingroup$ Sorry, I was not very clear. By "global queue" I was suggesting using sockets or channels. You can have multiple clients connect to the publisher to write state change events specifying whatever changes are required to the cloud objects and a single subscriber that processes the events and makes the changes. Unless I am missing something, that serialization should solve your problem. $\endgroup$ Jun 10, 2022 at 21:29
  • $\begingroup$ Thanks for the clarification, @Rohit. I have no experience managing/using sockets/channels in WL or otherwise, so it would be a steep learning curve for me. I'm still hoping for a simpler solution within the Wolfram Language. $\endgroup$
    – G. Shults
    Jun 12, 2022 at 15:59


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.