Loading...
Searching...
No Matches
timer.h
Go to the documentation of this file.
/*
libparted - a library for manipulating disk partitions
Copyright (C) 2001-2002, 2007, 2009-2014, 2019-2023, 2026 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/>.
*/
#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;
time_t start;
time_t now;
time_t predicted_end;
const char* state_name;
PedTimerHandler* handler;
void* context;
};
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 */
ped_timer_set_state_name
void ped_timer_set_state_name(PedTimer *timer, const char *state_name)
Definition timer.c:235
ped_timer_new
PedTimer * ped_timer_new(PedTimerHandler *handler, void *context)
Creates a timer.
Definition timer.c:66
ped_timer_destroy_nested
void ped_timer_destroy_nested(PedTimer *timer)
Destroys a nested timer.
Definition timer.c:148
ped_timer_reset
void ped_timer_reset(PedTimer *timer)
Definition timer.c:188
PedTimer
struct _PedTimer PedTimer
Definition timer.h:32
ped_timer_touch
void ped_timer_touch(PedTimer *timer)
Definition timer.c:167
ped_timer_new_nested
PedTimer * ped_timer_new_nested(PedTimer *parent, float nest_frac)
Creates a new nested timer.
Definition timer.c:124
ped_timer_update
void ped_timer_update(PedTimer *timer, float new_frac)
Definition timer.c:209
ped_timer_destroy
void ped_timer_destroy(PedTimer *timer)
Destroys a timer.
Definition timer.c:87
PedTimerHandler
void PedTimerHandler(PedTimer *timer, void *context)
Definition timer.h:34
_PedTimer
Definition timer.h:39
_PedTimer::frac
float frac
fraction of operation done
Definition timer.h:40
_PedTimer::handler
PedTimerHandler * handler
who to notify on updates
Definition timer.h:45
_PedTimer::start
time_t start
time of start of op
Definition timer.h:41
_PedTimer::context
void * context
context to pass to handler
Definition timer.h:46
_PedTimer::state_name
const char * state_name
eg: "copying data"
Definition timer.h:44
_PedTimer::now
time_t now
time of last update (now!)
Definition timer.h:42
_PedTimer::predicted_end
time_t predicted_end
expected finish time
Definition timer.h:43