Logo Search packages:      
Sourcecode: icu version File versions  Download package

U_STABLE void U_EXPORT2 u_setAtomicIncDecFunctions ( const void *  context,
UMtxAtomicFn inc,
UMtxAtomicFn dec,
UErrorCode status 

Set the functions that ICU will use for atomic increment and decrement of int32_t values. Use of this function is optional; by default (without this function), ICU will use its own internal implementation of atomic increment/decrement. This function can only be used when ICU is in an initial, unused state, before u_init() has been called.

context This pointer value will be saved, and then (later) passed as a parameter to the increment and decrement functions each time they are called. This function can only be called
inc Pointer to a function to do an atomic increment operation. Must be non-null.
dec Pointer to a function to do an atomic decrement operation. Must be non-null.
status Receives error values. ICU 2.8

Definition at line 557 of file umutex.c.


    if (U_FAILURE(*status)) {
    /* Can not set a mutex function to a NULL value  */
    if (ip==NULL || dp==NULL) {
        *status = U_ILLEGAL_ARGUMENT_ERROR;
    /* If ICU is not in an initial state, disallow this operation. */
    if (cmemory_inUse()) {
        *status = U_INVALID_STATE_ERROR;

    pIncFn = ip;
    pDecFn = dp;
    gIncDecContext = context;

        int32_t   testInt = 0;
        U_ASSERT(umtx_atomic_inc(&testInt) == 1);     /* Sanity Check.    Do the functions work at all? */
        U_ASSERT(testInt == 1);
        U_ASSERT(umtx_atomic_dec(&testInt) == 0);
        U_ASSERT(testInt == 0);

Generated by  Doxygen 1.6.0   Back to index