OpenSCADAWiki: Home Page En/Doc/API/part16
 

16. Resources in the OpenSCADA system (Res, ResAlloc, ResMtx, MtxAlloc, AutoHD)

Most of the units and subsystems of the OpenSCADA are dynamic, ie they allow the creation/deletion/configuration while the system is working. Taking into account the multi-threading of the system, this functionality imposes stringent requirements for synchronization of threads. For synchronization in the system the resources are used, functions of which are localized in the objects "Res" and "ResAlloc". Object "Res" provides storage of the resource, providing the functions of capture/release for the read and write. In object "ResAlloc" the automatic release of the resource functions are implemented. Automatic resource involves the creation of a local resource object with its automatic release at fracture (in the destructor). Using of automatic resource makes the work with resources when using the exceptions much easier.

Any dynamic system object is inherited from "TCntrNode" object, which contains a mechanism to connect via the "AutoHD" template. The main function of the template is to store the link to the object and the capture of the resource, excluding the deleting of the object at the time of use. Template supports copying the resource and its release in case of destruction of the template object. For clarity of the access to the objects generated by "TCntrNode" the "AutoHD" template supports casting, based on the dynamic cast.

16.1. Resource R/W lock object (ResRW)

Public methods:

16.2. Automatic resource RW unlock object (ResAlloc)

Public methods:

16.3. Template (AutoHD)

Public methods:

16.4. Resources allocation object, by mutex (ResMtx)

Public methods:

16.5. Object of the string with the access shared by the resource (ResString)

Public methods:

16.6. Conditional variable object, by mutex (CondVar)

Public methods:

16.7. Object of automatic unlock POSIX mutex (MtxAlloc)

Public methods:

16.8. Object of the string with the access shared by the global the data resource (mutex) (MtxString)

Public methods: