00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef DEBUG
00019 #define DEBUG
00020 #endif
00021
00022 #include <ucommon/ucommon.h>
00023
00024 #include <stdio.h>
00025
00026 using namespace UCOMMON_NAMESPACE;
00027
00028 static unsigned count = 0;
00029
00030 class testThread : public JoinableThread
00031 {
00032 public:
00033 testThread() : JoinableThread() {};
00034
00035 void run(void) {
00036 ++count;
00037 ::sleep(2);
00038 };
00039 };
00040
00041 extern "C" int main()
00042 {
00043 time_t now, later;
00044 testThread *thr;
00045
00046 time(&now);
00047 thr = new testThread();
00048 start(thr);
00049 Thread::sleep(10);
00050 delete thr;
00051 assert(count == 1);
00052 time(&later);
00053 assert(later >= now + 1);
00054
00055 time(&now);
00056 TimedEvent evt;
00057 evt.wait(2000);
00058 time(&later);
00059 assert(later >= now + 1);
00060 return 0;
00061 }
00062