diff --git a/src/libCom/test/Makefile b/src/libCom/test/Makefile index 6c3da8972..08f29b04c 100644 --- a/src/libCom/test/Makefile +++ b/src/libCom/test/Makefile @@ -31,6 +31,10 @@ epicsTimerTestHost_SRCS += epicsTimerTestMain.cpp epicsTimerTest.cpp PROD_HOST += epicsTimerTestHost OBJS_IOC += epicsTimerTest +epicsTimerExampleHost_SRCS += epicsTimerExampleMain.cpp epicsTimerExample.cpp +PROD_HOST += epicsTimerExampleHost +OBJS_IOC += epicsTimerExample + ringPointerTestHost_SRCS += ringPointerTestMain.cpp ringPointerTest.c PROD_HOST += ringPointerTestHost OBJS_IOC += ringPointerTest diff --git a/src/libCom/test/epicsTimerExample.cpp b/src/libCom/test/epicsTimerExample.cpp new file mode 100644 index 000000000..dee90b089 --- /dev/null +++ b/src/libCom/test/epicsTimerExample.cpp @@ -0,0 +1,31 @@ +#include + +#include "epicsTimer.h" + +class something : public epicsTimerNotify { +public: + something(const char* nm,epicsTimerQueueActive &queue) + : name(nm), timer(queue.createTimer()) {} + virtual ~something() { timer.destroy();} + void start(double delay) {timer.start(*this,delay);} + virtual expireStatus expire(const epicsTime & currentTime) { + printf("%s\n",name); + currentTime.show(1); + return(noRestart); + } +private: + const char* name; + epicsTimer &timer; +}; + +void epicsTimerExample() +{ + epicsTimerQueueActive &queue = epicsTimerQueueActive::allocate(true); + something first("first",queue); + something second("second",queue); + + first.start(1.0); + second.start(1.5); + epicsThreadSleep(2.0); + queue.release(); +} diff --git a/src/libCom/test/epicsTimerExampleMain.cpp b/src/libCom/test/epicsTimerExampleMain.cpp new file mode 100644 index 000000000..b7d7bf332 --- /dev/null +++ b/src/libCom/test/epicsTimerExampleMain.cpp @@ -0,0 +1,38 @@ + +/* + * $Id$ + * + * Author Jeffrey O. Hill + * johill@lanl.gov + * 505 665 1831 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1991, the Regents of the University of California, + * and the University of Chicago Board of Governors. + * + * This software was produced under U.S. Government contracts: + * (W-7405-ENG-36) at the Los Alamos National Laboratory, + * and (W-31-109-ENG-38) at Argonne National Laboratory. + * + * Initial development by: + * The Controls and Automation Group (AT-8) + * Ground Test Accelerator + * Accelerator Technology Division + * Los Alamos National Laboratory + * + * Co-developed with + * The Controls and Computing Group + * Accelerator Systems Division + * Advanced Photon Source + * Argonne National Laboratory + * + */ + +void epicsTimerExample ( void ); + +int main ( int /* argc */, char /* *argv[] */ ) +{ + epicsTimerExample (); + return 0; +}