# # Copyright (c) 2015 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # =head1 NAME NACL::MTask::ClientSingleton =head1 SYNOPSIS my @Clients = NACL::MTask::ClientSingleton->find(); =head1 DESCRIPTION C returns a singleton of a NACL::C::Client. This is useful if you want to limit the number of duplicate connections to a client but are unable to pass references between modules. =head1 METHODS =head2 find my @Clients = NACL::MTask::ClientSingleton->find(); my $Client = NACL::MTask::ClientSingleton->find(); Get a C instance or instances. =cut package NACL::MTask::ClientSingleton; use NACL::C::Client; my @Clients; sub find { my ($pkg, %args) = @_; if (!@Clients) { @Clients = NACL::C::Client->find(%args); } return wantarray ? @Clients : $Clients[0]; } 1;