package placeholder;
use strict;
1;

sub new {
    my $class = shift;
    my($id) = @_;
    my $self = {
        id => $id,
        implementation => undef,
        queue => [],
    };
    bless($self, $class);
    $self->load();
    return $self;
}

sub load {
    my $self = shift;
    # set off the load
    # ...
    # once the load is done, set $self->{implementation} to the actual object and call $self->flushqueue();
}

sub flushqueue {
    my $self = shift;
    foreach my $entry (@{$self->{queue}}) {
        $self->{implementation}->$entry->{method}(@{$entry->{arguments}});
    }
    $self->{queue} = undef;
}

sub AUTOLOAD {
    my $self = shift;
    if (defined($self->{implementation})) {
        goto &{$self->{implementation}->$AUTOLOAD};
    } else {
        push(@{$self->{queue}}, {
            method => $AUTOLOAD,
            arguments => [@_],
        });
    }
}
