handler

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2024 License: MIT Imports: 1 Imported by: 1

Documentation

Overview

Package handler provides datastructures for handlers which can be used to abort potentially long-running computations in LogicNG. There are some standard handlers like timeout handler already implemented in LogicNG. If you need other criteria when to abort computations, you can implement the Handler interface yourself.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Aborted

func Aborted(handler Handler) bool

Aborted returns true when the given handler is not nil and the computation was aborted by this handler.

func Start

func Start(handler Handler)

Start starts the given handler it is not nil.

Types

type Computation

type Computation struct {
	// contains filtered or unexported fields
}

Computation is a simple computation handler which can be embedded in more complex handlers.

func (*Computation) Aborted

func (c *Computation) Aborted() bool

Aborted reports whether the computation was aborted by the handler.

func (*Computation) SetAborted

func (c *Computation) SetAborted(aborted bool)

SetAborted sets whether the computation was aborted.

func (*Computation) Started

func (c *Computation) Started()

Started indicates the handler that the computation was started.

type Handler

type Handler interface {
	Started()
	Aborted() bool
}

A Handler can be used to abort computations. The Started method is called when the computation is started. The Aborted method returns whether the computation was aborted by the handler.

type Timeout

type Timeout struct {
	Computation
	// contains filtered or unexported fields
}

A Timeout handler is used to abort computations after a given time.

func NewTimeoutWithDuration

func NewTimeoutWithDuration(duration time.Duration) *Timeout

NewTimeoutWithDuration generates a new timeout handler which aborts a computation after the given duration.

func NewTimeoutWithEnd

func NewTimeoutWithEnd(time time.Time) *Timeout

NewTimeoutWithEnd generates a new timeout handler which aborts a computation at the given time.

func (*Timeout) Aborted

func (t *Timeout) Aborted() bool

Aborted reports whether the computation was aborted by the handler.

func (*Timeout) TimeLimitExceeded

func (t *Timeout) TimeLimitExceeded() bool

TimeLimitExceeded reports whether the internal time limit of the handler was exceeded.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL