Lines Matching defs:dog
21 * \brief Watch dog for detecting timeouts
62 qpWatchDog* dog = (qpWatchDog*)arg;
63 DE_ASSERT(dog);
67 while (dog->status == STATUS_THREAD_RUNNING)
70 int totalSecondsPassed = (int)((curTime - dog->resetTime) / 1000000ull);
71 int secondsSinceLastTouch = (int)((curTime - dog->lastTouchTime) / 1000000ull);
73 if ((secondsSinceLastTouch > dog->intervalTimeLimit) || (totalSecondsPassed > dog->totalTimeLimit))
76 dog->timeOutFunc(dog, dog->timeOutUserPtr);
89 qpWatchDog* dog = (qpWatchDog*)deCalloc(sizeof(qpWatchDog));
90 if (!dog)
91 return dog;
98 dog->timeOutFunc = timeOutFunc;
99 dog->timeOutUserPtr = userPtr;
100 dog->totalTimeLimit = totalTimeLimitSecs;
101 dog->intervalTimeLimit = intervalTimeLimitSecs;
104 qpWatchDog_reset(dog);
107 dog->status = STATUS_THREAD_RUNNING;
108 dog->watchDogThread = deThread_create(watchDogThreadFunc, dog, DE_NULL);
109 if (!dog->watchDogThread)
111 deFree(dog);
115 return dog;
118 void qpWatchDog_reset (qpWatchDog* dog)
122 DE_ASSERT(dog);
125 dog->resetTime = curTime;
126 dog->lastTouchTime = curTime;
129 void qpWatchDog_destroy (qpWatchDog* dog)
131 DE_ASSERT(dog);
135 dog->status = STATUS_STOP_THREAD;
136 deThread_join(dog->watchDogThread);
137 deThread_destroy(dog->watchDogThread);
140 deFree(dog);
143 void qpWatchDog_touch (qpWatchDog* dog)
145 DE_ASSERT(dog);
147 dog->lastTouchTime = deGetMicroseconds();