libparted 3.6
Loading...
Searching...
No Matches
timer.h
Go to the documentation of this file.
1/*
2 libparted - a library for manipulating disk partitions
3 Copyright (C) 2001-2002, 2007, 2009-2014, 2019-2023 Free Software
4 Foundation, Inc.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
27#ifndef PED_TIMER_H_INCLUDED
28#define PED_TIMER_H_INCLUDED
29
30#include <time.h>
31
32typedef struct _PedTimer PedTimer;
33
34typedef void PedTimerHandler (PedTimer* timer, void* context);
35
36/*
37 * Structure keeping track of progress and time
38 */
39struct _PedTimer {
40 float frac;
41 time_t start;
42 time_t now;
44 const char* state_name;
46 void* context;
47};
48
49extern PedTimer* ped_timer_new (PedTimerHandler* handler, void* context);
50extern void ped_timer_destroy (PedTimer* timer);
51
52/* a nested timer automatically notifies it's parent. You should only
53 * create one when you are going to use it (not before)
54 */
55extern PedTimer* ped_timer_new_nested (PedTimer* parent, float nest_frac);
56extern void ped_timer_destroy_nested (PedTimer* timer);
57
58extern void ped_timer_touch (PedTimer* timer);
59extern void ped_timer_reset (PedTimer* timer);
60extern void ped_timer_update (PedTimer* timer, float new_frac);
61extern void ped_timer_set_state_name (PedTimer* timer, const char* state_name);
62
63#endif /* PED_TIMER_H_INCLUDED */
64
65
void ped_timer_set_state_name(PedTimer *timer, const char *state_name)
Definition: timer.c:235
PedTimer * ped_timer_new(PedTimerHandler *handler, void *context)
Creates a timer.
Definition: timer.c:66
void ped_timer_destroy_nested(PedTimer *timer)
Destroys a nested timer.
Definition: timer.c:148
void ped_timer_reset(PedTimer *timer)
Definition: timer.c:188
void ped_timer_touch(PedTimer *timer)
Definition: timer.c:167
PedTimer * ped_timer_new_nested(PedTimer *parent, float nest_frac)
Creates a new nested timer.
Definition: timer.c:124
void ped_timer_update(PedTimer *timer, float new_frac)
Definition: timer.c:209
void ped_timer_destroy(PedTimer *timer)
Destroys a timer.
Definition: timer.c:87
void PedTimerHandler(PedTimer *timer, void *context)
Definition: timer.h:34
Definition: timer.h:39
float frac
fraction of operation done
Definition: timer.h:40
PedTimerHandler * handler
who to notify on updates
Definition: timer.h:45
time_t start
time of start of op
Definition: timer.h:41
void * context
context to pass to handler
Definition: timer.h:46
const char * state_name
eg: "copying data"
Definition: timer.h:44
time_t now
time of last update (now!)
Definition: timer.h:42
time_t predicted_end
expected finish time
Definition: timer.h:43