API

XWC app semaphore Utilities to use CRTP derived classes. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define XWC_SEM_WAIT_TS_RETVOID_DERIVED(ts, sec, nsec)
 Add the wait time to a timespec for a sem_timedwait call, with no value returned on error, using the derived class. More...
 
#define XWC_SEM_WAIT_TS_DERIVED(ts, sec, nsec)
 Add the wait time to a timespec for a sem_timedwait call, with -1 returned on error. More...
 
#define XWC_SEM_TIMEDWAIT_LOOP_DERIVED(sem, ts)
 Perform a sem_timedwait in the context of a standard loop in MagAO-X code using the derived class. More...
 
#define XWC_SEM_FLUSH_DERIVED(sem)
 

Detailed Description

XWC app semaphore Utilities to use CRTP derived classes.

Author
Jared R. Males (jared.nosp@m.male.nosp@m.s@gma.nosp@m.il.c.nosp@m.om)

Definition in file semUtilsDerived.hpp.

Macro Definition Documentation

◆ XWC_SEM_FLUSH_DERIVED

#define XWC_SEM_FLUSH_DERIVED (   sem)
Value:
{ \
int semval; \
if(sem_getvalue( &sem, &semval)<0) \
{ \
return derivedT::template log<software_error,-1>({__FILE__, __LINE__,errno, "sem_getvalue"}); \
} \
for(int i = 0; i < semval; ++i) \
{ \
if(sem_trywait(&sem) != 0) \
{ \
if(errno == EAGAIN) break; \
return derivedT::template log<software_error,-1>({__FILE__, __LINE__,errno, "sem_trywait"}); \
} \
} \
}

Definition at line 65 of file semUtilsDerived.hpp.

◆ XWC_SEM_TIMEDWAIT_LOOP_DERIVED

#define XWC_SEM_TIMEDWAIT_LOOP_DERIVED (   sem,
  ts 
)
Value:
if(sem_timedwait(&sem, &ts) != 0) \
{ \
/* Check for why we timed out */ \
/* EINTER probably indicates time to shutdown, loop wil exit if m_shutdown is set */ \
/* ETIMEDOUT just means keep waiting */ \
if(errno == EINTR || errno == ETIMEDOUT) continue; \
\
/*Otherwise, report an error.*/ \
derivedT::template log<software_error>({__FILE__, __LINE__,errno, "sem_timedwait"}); \
break; \
}

Perform a sem_timedwait in the context of a standard loop in MagAO-X code using the derived class.

Parameters
semthe semaphore
tsthe timespec with the time to wait until

Definition at line 52 of file semUtilsDerived.hpp.

◆ XWC_SEM_WAIT_TS_DERIVED

#define XWC_SEM_WAIT_TS_DERIVED (   ts,
  sec,
  nsec 
)
Value:
if(clock_gettime(CLOCK_REALTIME, &ts) < 0) \
{ \
derivedT::template log<software_critical>({__FILE__,__LINE__,errno,0,"clock_gettime"}); \
return -1; \
} \
ts.tv_sec += sec; \
mx::sys::timespecAddNsec(ts, nsec);

Add the wait time to a timespec for a sem_timedwait call, with -1 returned on error.

An error would be generated by clock_gettime

Parameters
tsis the timespec to modify, should be set to current time
secis the number of seconds to add to ts
nsecis the number of nanoseconds to add to ts

Definition at line 37 of file semUtilsDerived.hpp.

◆ XWC_SEM_WAIT_TS_RETVOID_DERIVED

#define XWC_SEM_WAIT_TS_RETVOID_DERIVED (   ts,
  sec,
  nsec 
)
Value:
if(clock_gettime(CLOCK_REALTIME, &ts) < 0) \
{ \
derivedT::template log<software_critical>({__FILE__,__LINE__,errno,0,"clock_gettime"}); \
return; /*will trigger a shutdown*/ \
} \
ts.tv_sec += sec; \
mx::sys::timespecAddNsec(ts, nsec);

Add the wait time to a timespec for a sem_timedwait call, with no value returned on error, using the derived class.

An error would be generated by clock_gettime.

Parameters
tsis the timespec to modify, should be set to current time
secis the number of seconds to add to ts
nsecis the number of nanoseconds to add to ts

Definition at line 20 of file semUtilsDerived.hpp.