You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Asynchronous calls are mechanisms to execute actions in a decoupled fashion. There are different approaches for asynchronous calls, depending on the level of control that is required. Some of them are offered by CORBA, ACS and BACI implementations. For instance we have:

  • threading: Programming Language feature
  • queuing: Design/Programming Language
  • oneway: CORBA functionality
  • offshoot: ACS functionality
  • callbacks: offshoot specialization by ACS
  • actions: BACI implementation based on callbacks

Asynchronous Mechanism

Threading

One approach for asynchronous calls based on the programming language functionality, is simply to use threading inside a method call, to execute the action in a separate thread and to return instantaneously.

void calibrateSync() {
  // do calibration...
}

void ExampleImpl::calibrate() {
    new std::thread(calibrateSync); //Thread resources are never de-allocated for simplicity
}

Queuing

A second approach based on design and programming language alone, is to populate queues with the actions that will be orchestrated by a separate thread.

void calibrateSync() {
    // do calibration...
}

//Function running on some other thread...
void run() {
    if (queue.size() > 0) {
        if (queue.pop() == CALIBRATE_ACTION) {
            calibrateSync();
        } else {
            //Some error
        }
    }
}

void ExampleImpl::calibrate() {
    queue.push(CALIBRATE_ACTION);
}

Oneway

Oneway is a concept in CORBA that is defined as a keyword in the IDL interface methods, which makes sure the caller continues with the execution without waiting for anything from the client. This is similar to threading/queuing options, but is stronger, in the sense that it is not possible to receive a return value nor to raise an exception.

The IDL itself has the information about the asynchronous mechanism:

interface Example: ... {
    ...
    oneway void calibrate();
    ...
}

The actual implementation is very simple:

void ExampleImpl::calibrate() {
    // do calibration...
}

Reporting on Asynchronous Calls

Offshoots

Offshoots are the most basic form to report back to the caller. The base interface is actually empty:

interface OffShoot {};

This is by design, allowing anyone to extend such interface as they prefer. For instance:

module Definitions {
    interface SimpleCallback : ACS::OffShoot {
        oneway void report(in boolean error);
    };
};

Has a single method that can be called 'report', which has an 'in' parameter, stating whether there was an error. It could be used in the 'calibrate' example as follows:

interface Example: ... {
    ...
    oneway void calibrate(in Definitions::SimpleCallback cB);
    ...
}

Which would lead to an implementation (Assuming the oneway case) as follows:

void ExampleImpl::calibrate(SimpleCallback* cb) {
    // do calibration...
    cb->report(status);
}

The offshoot can be used with either of the 3 asynchronous mechanisms, and you will have to decide on one of them depending on your preferences and a trade-off limitations/requirements from each approach.

Callbacks

Callbacks are in fact a specialization of the Offshoot and are

BACI Actions

  • No labels