leshan icon indicating copy to clipboard operation
leshan copied to clipboard

Enhance LWM2M tree synchronizaton mechanism at client side

Open sbernard31 opened this issue 3 years ago • 3 comments

Currently thread synchronization at client side was done thanks to synchronized block at LWM2M Object level (BaseObjectEnabler)

With the addition of WriteComposite(#959) and the need to apply operation at LWM2M Root Level in an atomic way and so this is probably no more enough.

We should maybe introduce a new locking interface which allow to implement different lock strategy. This interface should provide a way get lock for a given LWM2M Node :

public inteface LwM2mLock {
    Lock readLock(LwM2mPath path)
    Lock writeLock(LwM2mPath path)
}

We can imagine several implementation like :

  • single lock
  • multi granularity lock (https://github.com/khilangudka/java-multilocks, https://github.com/evolvedbinary/multilock)

I'm not so sure, just an idea.

Some more resources :

  • https://stackoverflow.com/questions/6154302/what-strategy-to-use-in-java-for-hierarchical-reentrant-read-write-locking
  • https://stackoverflow.com/questions/9301631/hierarchical-mutex-locks-in-java

sbernard31 avatar Jan 29 '21 16:01 sbernard31

@moznion, do you already feel you need something like this ?

sbernard31 avatar Jan 29 '21 16:01 sbernard31

Hmm, it looks interesting. To be honest, I've not felt like that gimmick needed for me until now, but I think introducing the lock mechanism is a good idea.

moznion avatar Feb 04 '21 14:02 moznion

Does it means that a global lock at tree level will be enough for you ?

sbernard31 avatar Feb 04 '21 15:02 sbernard31