示例#1
0
文件: access.cpp 项目: ukaea/epics
// extern "C"
void epicsShareAPI ca_signal_formated ( long ca_status, const char *pfilenm, 
                                       int lineno, const char *pFormat, ... )
{
    ca_client_context *pcac;

    if ( caClientContextId ) {
        pcac = ( ca_client_context * ) epicsThreadPrivateGet ( caClientContextId );
    }
    else {
        pcac = 0;
    }

    va_list theArgs;
    va_start ( theArgs, pFormat );  
    if ( pcac ) {
        pcac->vSignal ( ca_status, pfilenm, lineno, pFormat, theArgs );
    }
    else {
        fprintf ( stderr, "CA exception in thread w/o CA ctx: status=%s file=%s line=%d: \n", 
            ca_message ( ca_status ), pfilenm, lineno );
        if ( pFormat ) {
            vfprintf ( stderr, pFormat, theArgs );
        }
    }
    va_end ( theArgs );
}
示例#2
0
文件: access.cpp 项目: ukaea/epics
// extern "C"
int epicsShareAPI ca_context_create ( 
            ca_preemptive_callback_select premptiveCallbackSelect )
{
    ca_client_context *pcac;

    try {
        epicsThreadOnce ( & caClientContextIdOnce, ca_init_client_context, 0);
        if ( caClientContextId == 0 ) {
            return ECA_ALLOCMEM;
        }

        pcac = ( ca_client_context * ) epicsThreadPrivateGet ( caClientContextId );
	    if ( pcac ) {
            if ( premptiveCallbackSelect == ca_enable_preemptive_callback &&
                ! pcac->preemptiveCallbakIsEnabled() ) {
                return ECA_NOTTHREADED;
            }
		    return ECA_NORMAL;
	    }

        pcac = new ca_client_context ( 
            premptiveCallbackSelect == ca_enable_preemptive_callback );
	    if ( ! pcac ) {
		    return ECA_ALLOCMEM;
	    }

        epicsThreadPrivateSet ( caClientContextId, (void *) pcac );
    }
    catch ( ... ) {
        return ECA_ALLOCMEM;
    }
    return ECA_NORMAL;
}
示例#3
0
文件: access.cpp 项目: ukaea/epics
// extern "C"
void epicsShareAPI ca_self_test ()
{
    ca_client_context *pcac = (ca_client_context *) epicsThreadPrivateGet ( caClientContextId );
    if ( ! pcac ) {
        return;
    }
    pcac->selfTest ();
}
示例#4
0
文件: access.cpp 项目: ukaea/epics
int epicsShareAPI ca_preemtive_callback_is_enabled ()
{
    ca_client_context *pcac = (ca_client_context *) epicsThreadPrivateGet ( caClientContextId );
    if ( ! pcac ) {
        return 0;
    }
    return pcac->preemptiveCallbakIsEnabled ();
}
示例#5
0
epicsShareFunc void epicsExitCallAtThreadExits(void)
{
    exitPvt * pep;
    epicsThreadOnce ( & exitPvtOnce, exitPvtOnceFunc, 0 );
    pep = epicsThreadPrivateGet ( exitPvtPerThread );
    if ( pep ) {
        epicsExitCallAtExitsPvt ( pep );
        destroyExitPvt ( pep );
        epicsThreadPrivateSet ( exitPvtPerThread, 0 );
    }
}
示例#6
0
文件: epicsStdio.c 项目: ukaea/epics
FILE * epicsShareAPI epicsGetThreadStderr(void)
{
    /* Deliberately don't do the epicsThreadOnce() here; epicsThreadInit()
     * is allowed to use stderr inside its once() routine, in which case we
     * must return the OS's stderr instead. There may be a tiny chance of a
     * race happening here during initialization for some architectures, so
     * we only use it for stderr to reduce the chance of that happening.
     */
    if (!stderrThreadPrivateId)
        return NULL;
    return epicsThreadPrivateGet(stderrThreadPrivateId);
}
示例#7
0
文件: access.cpp 项目: ukaea/epics
// extern "C"
int epicsShareAPI ca_attach_context ( struct ca_client_context * pCtx )
{
    ca_client_context *pcac = (ca_client_context *) epicsThreadPrivateGet ( caClientContextId );
    if ( pcac && pCtx != 0 ) {
        return ECA_ISATTACHED;
    }
    if ( ! pCtx->preemptiveCallbakIsEnabled() ) {
        return ECA_NOTTHREADED;
    }
    epicsThreadPrivateSet ( caClientContextId, pCtx );
    return ECA_NORMAL;
}
示例#8
0
文件: access.cpp 项目: ukaea/epics
// extern "C"
struct ca_client_context * epicsShareAPI ca_current_context ()
{
    struct ca_client_context *pCtx;
    if ( caClientContextId ) {
        pCtx = ( struct ca_client_context * ) 
            epicsThreadPrivateGet ( caClientContextId );
    }
    else {
        pCtx = 0;
    }
    return pCtx;
}
示例#9
0
文件: access.cpp 项目: ukaea/epics
//
// ca_context_destroy ()
//
// extern "C"
void epicsShareAPI ca_context_destroy ()
{
    ca_client_context   *pcac;

    if ( caClientContextId != NULL ) {
        pcac = (ca_client_context *) epicsThreadPrivateGet ( caClientContextId );
        if ( pcac ) {
            delete pcac;
            epicsThreadPrivateSet ( caClientContextId, 0 );
        }
    }
}
示例#10
0
epicsShareFunc int epicsAtThreadExit(epicsExitFunc func, void *arg)
{
    exitPvt * pep;
    epicsThreadOnce ( & exitPvtOnce, exitPvtOnceFunc, 0 );
    pep = epicsThreadPrivateGet ( exitPvtPerThread );
    if ( ! pep ) {
        pep = createExitPvt ();
        if ( ! pep ) {
            return -1;
        }
        epicsThreadPrivateSet ( exitPvtPerThread, pep );
    }
    return epicsAtExitPvt ( pep, func, arg );
}
示例#11
0
文件: access.cpp 项目: ukaea/epics
/*
 * fetchClientContext ();
 */
int fetchClientContext ( ca_client_context **ppcac )
{
    epicsThreadOnce ( &caClientContextIdOnce, ca_init_client_context, 0 );
    if ( caClientContextId == 0 ) {
        return ECA_ALLOCMEM;
    }

    int status;
    *ppcac = ( ca_client_context * ) epicsThreadPrivateGet ( caClientContextId );
    if ( *ppcac ) {
        status = ECA_NORMAL;
    }
    else {
        status = ca_task_initialize ();
        if ( status == ECA_NORMAL ) {
            *ppcac = (ca_client_context *) epicsThreadPrivateGet ( caClientContextId );
            if ( ! *ppcac ) {
                status = ECA_INTERNAL;
            }
        }
    }

    return status;
}
示例#12
0
文件: epicsStdio.c 项目: ukaea/epics
FILE * epicsShareAPI epicsGetThreadStdout(void)
{
    epicsThreadOnce(&onceId,once,0);
    return epicsThreadPrivateGet(stdoutThreadPrivateId);
}