ContextTracking.Context
— Typestruct Context{T}
Context is a container for storing any contextual information. It uses Memento pattern to keep track of prior history. While the context can be changed, explict save/restore can be used to save the current context and restore the most recently saved one.
Fields
id::UInt64
ID of the context
history::DataStructures.Stack{T} where T
History of context data
path::Array{Symbol,1}
Call path
ContextTracking.Context
— MethodContext(id::UInt64, container::T) -> Context{_A} where _A
Create a context with the provided container.
ContextTracking.context
— Methodcontext([id::UInt], [container])
Get a new context object. If id
is not passed, then return a global context for the current thread/task. The container
must be an object that supports push!
, getindex
, empty!
, and length
functions. The default is Dict{Any,Any}
.
ContextTracking.default_context_id
— Methoddefault_context_id()
Return a context name for the current thread.
ContextTracking.restore
— Methodrestore(c::Context) -> Any
Restore to the last saved context.
ContextTracking.save
— Methodsave(c::Context) -> DataStructures.Stack{_A} where _A
Save the current context to history.
ContextTracking.@ctx
— Macro@ctx <function definition> [label]
Define a function that is context-aware i.e. save the current context before executing the function and restore the context right before returning to the caller. So, if the function modifies the context using (see @memo
), then the change is not visible the caller. ```
ContextTracking.@memo
— Macro@memo var = expr
@memo var
Store the variable/value from the assigment statement in the current context.