You are viewing the version of this documentation from Perl 5.39.4. This is a development version of Perl.

CONTENTS

NAME

Test2::API::Instance - Object used by Test2::API under the hood

DESCRIPTION

This object encapsulates the global shared state tracked by Test2. A single global instance of this package is stored (and obscured) by the Test2::API package.

There is no reason to directly use this package. This package is documented for completeness. This package can change, or go away completely at any time. Directly using, or monkeypatching this package is not supported in any way shape or form.

SYNOPSIS

use Test2::API::Instance;

my $obj = Test2::API::Instance->new;
$pid = $obj->pid

PID of this instance.

$obj->tid

Thread ID of this instance.

$obj->reset()

Reset the object to defaults.

$obj->load()

Set the internal state to loaded, and run and stored post-load callbacks.

$bool = $obj->loaded

Check if the state is set to loaded.

$arrayref = $obj->post_load_callbacks

Get the post-load callbacks.

$obj->add_post_load_callback(sub { ... })

Add a post-load callback. If load() has already been called then the callback will be immediately executed. If load() has not been called then the callback will be stored and executed later when load() is called.

$hashref = $obj->contexts()

Get a hashref of all active contexts keyed by hub id.

$arrayref = $obj->context_acquire_callbacks

Get all context acquire callbacks.