Documentation ¶
Overview ¶
Package deferred provides tools for deferring actions to be run at a later time. These can be thought of as an extension and generalization of the language's built-in defer statement.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Queue ¶
type Queue []func()
A Queue is a queue of actions to run at some later time. The actions will be run in the order they are added with Defer. Note that this is different from the language's built-in defer statement, which runs actions in reverse order (future versions of this package may add a Stack type to support those semantics).
The zero value is an empty queue.
The advantage of this vs. built-in defer is that it needn't be tied to the scope of a single function; for example, you can write code like:
q := &Queue{} defer q.Run() f(q) // pass the queue to a subroutine, which may queue
// up actions to be run after *this* function returns.