cumbia 1.x
general purpose multi threaded library
|
Cumbia is a library that offers a carefree approach to multi thread application design and implementation. The user writes Activities and decides when their instances are started and to which thread they belong. A token is used to register an Activity and activities registered with the same token are run in the same thread. Work is done inside the init, execute and exit methods of an Activity. The library guarantees that the aforementioned methods are always called in the activity thread. From within init, execute and exit, computed results can be forwarded to the main execution thread, where they can be used to update a graphical interface.
cumbia-libs on github.io
Other cumbia modules |
---|
cumbia module. |
cumbia-tango module. |
cumbia-qtcontrols module. |
qumbia-tango-controls module. |
qumbia-epics module. |
qumbia-epics-controls module. |
qumbia-plugins module. |
cumbia plugins |
---|
formula plugin. |
dbus plugin. |
multi reader plugin. |
context menu actions plugin. |
These applications (and their documentation, that has already been mentioned in the Tutorials table above) must be installed from the qumbia-apps sub-directory of the cumbia-libs distribution. To install them, cd into that folder and execute:
Along the applications executables and documentation, two bash scripts will be installed:
They define shortcuts for the common operations provided by the qumbia-apps applications as follows.
Applications (command line) | description | app |
---|---|---|
cumbia new project | create a new cumbia project | qumbia-apps/qumbiaprojectwizard |
cumbia import | migrate a QTango project into cumbia | qumbia-apps/qumbiaprojectwizard |
cumbia new control | write a cumbia control reader or writer | qumbia-apps/qumbianewcontrolwizard |
cumbia ui make | run cuuimake to generate qt+cumbia ui_*.h files | qumbia-apps/cuuimake |
| cumbia client | run a generic cumbia client | qumbia-apps/cumbia_client | * | cumbia client | run a generic cumbia client | qumbia-apps/cumbia_client | | la-cumparsita | interpret a Qt designer ui file on the fly | qumbia-apps/cumbia_client |
bash auto completion will help you use these shortcuts: try
or
In asynchronous environments, threads have always posed some kind of challenge for the programmer. Shared data, message exchange, proper termination are some aspects that cannot be overlooked. The Android AsyncTask offers a simple approach to writing code that is executed in a separate thread. The API provides a method that is called in the secondary thread context and functions to post results on the main one.
Cumbia CuActivity’s purpose is to replicate the carefree approach supplied by the AsyncTask. In this respect, a CuActivity is an interface to allow subclasses do work within three specific methods: init, execute and onExit. Therein, the code is run in a separate thread. The publishProgress and publishResult methods hand data to the main thread. To accomplish all this, an event loop must be running. By an initial parametrization, either a custom one (such as Qt’s, used in qumbia-qtcontrols) or the builtin cumbia CuEventLoop can be installed. New activities must be registered in the CuActivityManager service, and unregistered when they are no longer needed. In this way, a token can be used to group several activities by a smaller number of threads. In other words, activities with the same token run in the same thread.
By means of the reference to the Cumbia instance, that must be maintained throughout the entire life of an application, you can access services. They are registered in the CuServiceProvider and accessed by name. The activity manager, the thread and the log services are some examples, but others can be written and installed, as long as they adhere to the CuServiceI interface (e.g cumbia-tango’s CuActionFactoryService and CuDeviceFactoryService). Cumbia can be subclassed in order to provide additional features specific to the engine employed. CumbiaPool allows to register and use multiple engines in the same application.
Data transfer is realised with the aid of the CuData and CuVariant classes. The former is a bundle pairing keys to values. The latter memorises data and implements several methods to store, extract and convert it to different types and formats. The cumbia-qtcontrols module handles these structures to provide a primary data display facility, unaware of the specific engine underneath (Tango, Epics, ...)