gi-glib-2.0.29: GLib bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | Safe-Inferred
Language | Haskell2010

GI.GLib.Structs.Timer

Contents

- Exported types
- Methods
  - continue
  - destroy
  - elapsed
  - isActive
  - reset
  - start
  - stop

Description

`GTimer` records a start time, and counts microseconds elapsed since that time.

This is done somewhat differently on different platforms, and can be tricky to get exactly right, so `GTimer` provides a portable/convenient interface.

Synopsis

- newtype Timer = Timer (ManagedPtr Timer)
- timerContinue :: (HasCallStack, MonadIO m) => Timer -> m ()
- timerDestroy :: (HasCallStack, MonadIO m) => Timer -> m ()
- timerElapsed :: (HasCallStack, MonadIO m) => Timer -> CULong -> m Double
- timerIsActive :: (HasCallStack, MonadIO m) => Timer -> m Bool
- timerReset :: (HasCallStack, MonadIO m) => Timer -> m ()
- timerStart :: (HasCallStack, MonadIO m) => Timer -> m ()
- timerStop :: (HasCallStack, MonadIO m) => Timer -> m ()

# Exported types

newtype Timer Source #

Memory-managed wrapper type.

Constructors

Timer (ManagedPtr Timer) |

#### Instances

Instances details

Eq Timer Source # |
Instance details Defined in GI.GLib.Structs.Timer Methods (==) :: Timer -> Timer -> Bool Source # (/=) :: Timer -> Timer -> Bool Source #
BoxedPtr Timer Source # |
Instance details Defined in GI.GLib.Structs.Timer Methods boxedPtrCopy :: Timer -> IO Timer Source # boxedPtrFree :: Timer -> IO () Source #
ManagedPtrNewtype Timer Source # |
Instance details Defined in GI.GLib.Structs.Timer Methods toManagedPtr :: Timer -> ManagedPtr Timer Source #

# Methods

### Click to display all available methods, including inherited ones

Expand

#### Methods

continue, destroy, elapsed, isActive, reset, start, stop.

#### Getters

None.

#### Setters

None.

## continue

timerContinue Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Timer | `timer`: a `Timer`.
-> m () |

Resumes a timer that has previously been stopped with `timerStop`. `timerStop` must be called before using this function.

Since: 2.4

## destroy

timerDestroy Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Timer | `timer`: a `Timer` to destroy.
-> m () |

Destroys a timer, freeing associated resources.

## elapsed

timerElapsed Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Timer | `timer`: a `Timer`.
-> CULong | `microseconds`: return location for the fractional part of seconds elapsed, in microseconds (that is, the total number of microseconds elapsed, modulo 1000000), or `Nothing`
-> m Double | Returns: seconds elapsed as a floating point value, including any fractional part.

If `timer` has been started but not stopped, obtains the time since the timer was started. If `timer` has been stopped, obtains the elapsed time between the time it was started and the time it was stopped. The return value is the number of seconds elapsed, including any fractional part. The `microseconds` out parameter is essentially useless.

## isActive

timerIsActive Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Timer | `timer`: a `Timer`.
-> m Bool | Returns: `True` if the timer is running, `False` otherwise

Exposes whether the timer is currently active.

Since: 2.62

## reset

timerReset Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Timer | `timer`: a `Timer`.
-> m () |

This function is useless; it's fine to call `timerStart` on an already-started timer to reset the start time, so `timerReset` serves no purpose.

## start

timerStart Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Timer | `timer`: a `Timer`.
-> m () |

Marks a start time, so that future calls to `timerElapsed` will report the time since `timerStart` was called. `g_timer_new()` automatically marks the start time, so no need to call `timerStart` immediately after creating the timer.

## stop

timerStop Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Timer | `timer`: a `Timer`.
-> m () |

Marks an end time, so calls to `timerElapsed` will return the difference between this end time and the start time.