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