Implementing operationComplete()

ostc_ServerOperation::operationComplete()

virtual void operationComplete(ostc_OperationResult*) const;

Performs any required cleanup after execute() and associated executions of format() complete.

For a given class that you derive from ostc_ServerOperation, you can either implement this function in the subtype, or use the default version as inherited from ostc_ServerOperation.

The Component Server calls this function after the operation results have been formatted and sent to the thin client. If the result is incremental, the Server calls the function after the first batch of results has been sent.

The default version calls delete on the os_cursor* and os_collection* (if nonzero) that execute() passes to ostc_OperationResult::setReturnValue():

void ostc_ServerOperation::operationComplete(
      ostc_OperationResult * result
) const
{
      os_collection * coll;
      os_cursor * cursor;

      result->getReturnValue(coll, cursor);

      if (coll)
            delete coll;

      if (cursor)
            delete cursor;
}

The Server calls this function within an ObjectStore transaction. You do not have to start a transaction explicitly in order to access persistent data within this function.

Your implementation of operationComplete() must be reentrant. That is, you are responsible for synchronizing access to any transient state that could be shared across Server threads. In addition, for operations that use shared_update transactions, you must synchronize access to persistent data if that is necessary to prevent interference among threads.



[previous] [next]