Lines Matching defs:timer

19 /** \file timer.c */
32 * When you create a PedTimer, you must specify a timer handler function.
35 * Timers may be nested. When a timer is constructed, you can choose
38 * this case, the nested timer's handler is internal to libparted,
57 * \brief Creates a timer.
67 PedTimer* timer;
71 timer = (PedTimer*) ped_malloc (sizeof (PedTimer));
72 if (!timer)
75 timer->handler = handler;
76 timer->context = context;
77 ped_timer_reset (timer);
78 return timer;
83 * \brief Destroys a \p timer.
86 ped_timer_destroy (PedTimer* timer)
88 if (!timer)
91 free (timer);
94 /* This function is used by ped_timer_new_nested() as the timer->handler
98 _nest_handler (PedTimer* timer, void* context)
104 ncontext->start_frac + ncontext->nest_frac * timer->frac);
109 * \brief Creates a new nested timer.
111 * This function creates a "nested" timer that describes the progress
112 * of a subtask. \p parent is the parent timer, and \p nested_frac is
114 * spent doing the nested timer's operation. The timer should only be
118 * back through to the parent task's timer.
120 * \return nested timer
144 * \brief Destroys a nested \p timer.
147 ped_timer_destroy_nested (PedTimer* timer)
149 if (!timer)
152 free (timer->context);
153 ped_timer_destroy (timer);
162 * First it updates \p timer->now and recomputes \p timer->predicted_end,
166 ped_timer_touch (PedTimer* timer)
168 if (!timer)
171 timer->now = time (NULL);
172 if (timer->now > timer->predicted_end)
173 timer->predicted_end = timer->now;
175 timer->handler (timer, timer->context);
181 * \brief This function sets the \p timer into a "start of task" position.
183 * It resets the \p timer, by setting \p timer->start and \p timer->now
187 ped_timer_reset (PedTimer* timer)
189 if (!timer)
192 timer->start = timer->now = timer->predicted_end = time (NULL);
193 timer->state_name = NULL;
194 timer->frac = 0;
196 ped_timer_touch (timer);
202 * \brief This function tells a \p timer what fraction \p frac of the task
205 * Sets the new \p timer->frac, and calls ped_timer_touch().
208 ped_timer_update (PedTimer* timer, float frac)
210 if (!timer)
213 timer->now = time (NULL);
214 timer->frac = frac;
217 timer->predicted_end
218 = timer->start
219 + (long) ((timer->now - timer->start) / frac);
221 ped_timer_touch (timer);
228 * \p timer describes.
234 ped_timer_set_state_name (PedTimer* timer, const char* state_name)
236 if (!timer)
239 timer->state_name = state_name;
240 ped_timer_touch (timer);