Inspirel banner

Programming Distributed Systems with YAMI4

3.10 Locking

The parameters object is very flexible in its ability to host various data and even simple hierarchical data structures. In more elaborated systems the internal structure of the message contents can become quite complex in which case it might make sense to divide the whole process of filling the parameters object with application data into phases, each performed by a different software component or system layer.

The locking mechanism allows programmers to implement a very simple and effective protection against accidental modification of the data that was already supposed to be fixed. In other words, locking can protect the data in the parameters object from being overwritten elsewhere in the program, until it is unlocked.

Locking and unlocking have the granularity of single entry, with the exception that when the nested entry is locked or unlocked, it is processed recursively.

In order to lock a particular entry an arbitrary key value needs to be provided, which is of the long integer type. The same value can be used to unlock the entry to allow its further modifications.

Since the locking mechanism is only addressing the accidental data modification within the same program and is not supposed to provide any means of remote protection across nodes in the distributed systems (in other words, locks are local), a typical usage will involve the generation of random key values that are discarded after use.

3.10.1 Ada

3.10.2 C++

3.10.3 Java

3.10.4 .NET

3.10.5 Python