leshan
leshan copied to clipboard
Enhance LWM2M tree synchronizaton mechanism at client side
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
@moznion, do you already feel you need something like this ?
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.
Does it means that a global lock at tree level will be enough for you ?