NAME
DBIO::Future::Immediate - Dependency-free immediate Future for DBIO's 'immediate' async mode
VERSION
version 0.900001
SYNOPSIS
use DBIO::Future::Immediate;
my $f = DBIO::Future::Immediate->done('hello', 'world');
ok $f->is_ready;
is_deeply [$f->get], ['hello', 'world'];
my $f2 = $f->then(sub { return uc $_[0] });
is_deeply [$f2->get], ['HELLO'];
my $err = DBIO::Future::Immediate->fail('something broke');
ok $err->is_failed;
See t/test/09_async.t for a runnable example.
DESCRIPTION
The production Future backend for DBIO's immediate async mode (ADR 0030). A self-contained Future implementation that requires no CPAN Future and no event loop framework: every operation completes synchronously, in-process.
It implements the DBIO::Future contract (done/fail/get/then/catch/is_ready/is_failed/needs_all), so *_async methods can return a real Future even when there is no async backend wired up. then chains run immediately, get returns instantly, and is_ready is always true.
METHODS
done
my $f = DBIO::Future::Immediate->done(@values);
Create an immediately-resolved successful Future.
fail
my $f = DBIO::Future::Immediate->fail($error);
Create an immediately-resolved failed Future.
is_ready
Returns true (always, since immediate futures resolve immediately).
is_failed
Returns true if this Future was created with "fail".
get
Returns the resolved values. Dies if the Future failed.
then
my $f2 = $f->then(sub { my @result = @_; return $fc->done(@new_result) });
Executes the callback immediately with the resolved values and returns a new Future. If the callback dies, returns a failed Future. If this Future is failed, returns itself without calling the callback.
Like a real Future's then, a callback that returns a single Future is sequenced into (adopted), not wrapped as a value -- so a callback resolves with a multi-value list portably via return $fc->done(@list). (A bare return @list resolves correctly here, under list context, but collapses to a scalar element count under a real Future's then, which invokes a non-Future-returning callback in scalar context.) Any other return is wrapped as the resolved value(s).
catch
my $f2 = $f->catch(sub { my $error = shift; ... });
Executes the callback immediately with the error if this Future failed. Returns itself unchanged if successful.
and_then
my $f2 = $f->and_then(sub { return DBIO::Future::Immediate->done(...) });
Like "then" but expects the callback to return a Future object. Flattens nested Futures.
needs_all
my $f = DBIO::Future::Immediate->needs_all(@futures);
Returns a Future that resolves when all input Futures have resolved. Fails if any input Future fails. Results are collected in order.
AUTHOR
DBIO & DBIx::Class Authors
COPYRIGHT AND LICENSE
Copyright (C) 2026 DBIO Authors Portions Copyright (C) 2005-2025 DBIx::Class Authors Based on DBIx::Class, heavily modified.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.