mco_trans_rt_get_remaining_time

Prototype

    MCO_RET mco_trans_rt_get_remaining_time (mco_trans_h t,
                                             mco_interval_t* remaining)

Arguments

t
Transaction handle
remaining
Address of the output interval structure

Description

This function returns the time in milliseconds left until the deadline expires. The time is calculated based on the current number of dirty pages (pages that have been modified by the current transaction).

This function can be used by the deadline policy callbacks. For instance the pre-defined callback for the strict deadline policy mco_trans_rt_deadline_check is implemented as follows:

    MCO_RET mco_trans_rt_deadline_check(mco_trans_h t)
    {
        mco_db_connection_h con = (mco_db_connection_h)t;
        mco_interval_t remaining;

        MCO_RET ret = mco_trans_rt_get_remaining_time(t, &remaining);

        /* do not interrupt the rollback unless the deadline was
           adjusted explicitly */
        if (ret == MCO_S_OK && remaining <= 0 &&
        (con->trans.deadline != con->trans.orig_deadline ||
        !(con->trans.flags & MCO_TRANSDF_ROLLBACK)))
        {
                ret = MCO_E_INTERRUPTED;
        }

        return ret;
    }

Return Codes

MCO_S_OK
Interval obtained successfully
MCO_E_INTERRUPTED
Transaction was interrupted by timer, callback or another transaction

Files

Header file:
mco.h
Source file:
mcotrans.c
Library:
libmcolib.a