cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Concurrency

Highlighted
Newbie

Concurrency

Can I use a thing property as a mutex lock? Is there any guarantee that when events arrive at the same time, they wont all read the lock to be open at the same time and all try to lock it in the next operation?

3 REPLIES 3

Re: Concurrency

Hi Christiaan,

To get a lock you need to update a persistent property, if you update a persistent no one will update that Thing until the service you are it's done.

Carles.

Re: Concurrency

Thanks Carles.

So does that mean other services writing to the property at the same time will block, or will they simply fail to update it and continue execution? Can they still read it concurrently? If it blocks for the duration of the service, this implies I should put the code updating the property in its own service to minimize waiting time, right?

Re: Concurrency

No Property Blocking, whole Thing Blocking, any service trying to access to that Thing will be blocked - block not continue execution -.

Well I don't know the insights 100%, what you say it depends on how trasactions works and I still don't have all the clues What I mean, it's still if you put the updating property code inside a service, the transaction will be one the one on the wrapping service, then you will get blocking for the wall wrapping service not just the one that writes the property ( I've already have a Lock() generic service on my "Master" Generic ThingShape to be able to lock when I want --> I usually don't do it )

Carles.