Alien-Libjio
view release on metacpan or search on metacpan
lib/Alien/Libjio.pm view on Meta::CPAN
return 1;
}
__END__
=pod
=head1 NAME
Alien::Libjio - Utility package to install and locate libjio
=head1 VERSION
version 1.004
=head1 SYNOPSIS
use Alien::Libjio;
my $jio = Alien::Libjio->new;
my $ldflags = $jio->ldflags;
my $cflags = $jio->cflags;
=head1 DESCRIPTION
To ensure reliability, some file systems and databases provide support for
something known as journalling. The idea is to ensure data consistency by
creating a log of actions to be taken (called a Write Ahead Log) before
committing them to disk. That way, if a transaction were to fail due to a
system crash or other unexpected event, the write ahead log could be used to
finish writing the data.
While this functionality is often available with networked databases, it can
be a rather memory- and processor-intensive solution, even where reliable
writes are important. In other cases, the filesystem does not provide native
journalling support, so other tricks may be used to ensure data integrity,
such as writing to a separate temporary file and then overwriting the file
instead of modifying it in-place. Unfortunately, this method cannot handle
threaded operations appropriately.
Thankfully, Alberto Bertogli published a userspace C library called libjio
that can provide these features in a small (less than 1500 lines of code)
library with no external dependencies.
This package is designed to install it, and provide a way to get the flags
necessary to compile programs using it. It is particularly useful for Perl XS
programs that use it, such as B<IO::Journal>.
=head1 METHODS
=head2 Alien::Libjio->new
Creates a new C<Alien::Libjio> object, which essentially just has a few
convenience methods providing useful information like compiler and linker
flags.
Example code:
my $jio = Alien::Libjio->new();
This method will return an appropriate B<Alien::Libjio> object or throw an
exception on error.
=head2 $jio->installed
Determine if a valid installation of libjio has been detected in the system.
This method will return a true value if it is, or undef otherwise.
Example code:
print "okay\n" if $jio->installed;
=head2 $jio->version
Determine the installed version of libjio, as a string.
Currently versions are simply floating-point numbers, so you can treat the
version number as such, but this behaviour is subject to change.
Example code:
my $version = $jio->version;
=head2 $jio->ldflags
=head2 $jio->linker_flags
This returns the flags required to link C code with the local installation of
libjio (typically in the LDFLAGS variable). It is particularly useful for
building and installing Perl XS modules such as L<IO::Journal>.
In scalar context, it returns an array reference suitable for passing to
other build systems, particularly L<Module::Build>. In list context, it gives
a normal array so that C<join> and friends will work as expected.
Example code:
my $ldflags = $jio->ldflags;
my @ldflags = @{ $jio->ldflags };
my $ldstring = join(' ', $jio->ldflags);
# or:
# my $ldflags = $jio->linker_flags;
=head2 $jio->cflags
=head2 $jio->compiler_flags
This method returns the compiler option flags to compile C code which uses
the libjio library (typically in the CFLAGS variable). It is particularly
useful for building and installing Perl XS modules such as L<IO::Journal>.
Example code:
my $cflags = $jio->cflags;
my @cflags = @{ $jio->cflags };
my $ccstring = join(' ', $jio->cflags);
# or:
# my $cflags = $jio->compiler_flags;
=head2 $jio->method
( run in 1.134 second using v1.01-cache-2.11-cpan-98d9bbf8dc8 )