NAME

Mojo::IOLoop::Subprocess::Role::Sereal - Subprocesses with Sereal

SYNOPSIS

use Mojo::IOLoop;

# Operation that would block the event loop for 5 seconds
my $subprocess = Mojo::IOLoop->subprocess->with_roles('+Sereal')->with_sereal->run(
  sub {
    my $subprocess = shift;
    sleep 5;
    return '♥', 'Mojolicious';
  },
  sub {
    my ($subprocess, $err, @results) = @_;
    say "I $results[0] $results[1]!";
  }
);

# Start event loop if necessary
Mojo::IOLoop->start unless Mojo::IOLoop->is_running;

DESCRIPTION

Mojo::IOLoop::Subprocess::Role::Sereal provides a "with_sereal" method for Mojo::IOLoop::Subprocess objects that will update its serialize and deserialize attributes to use Sereal for data serialization. Sereal is faster than Storable and supports serialization of more reference types such as Regexp. The "FREEZE/THAW CALLBACK MECHANISM" in Sereal::Encoder is supported to control serialization of blessed objects.

See Mojo::IOLoop::Subprocess::Sereal for a method to retrieve a subprocess object using Sereal directly from Mojo::IOLoop.

METHODS

Mojo::IOLoop::Subprocess::Role::Sereal composes the following methods.

with_sereal

$subprocess = $subprocess->with_sereal;

Set "deserialize" in Mojo::IOLoop::Subprocess and "serialize" in Mojo::IOLoop::Subprocess to callbacks that use Sereal for data serialization.

BUGS

Report any issues on the public bugtracker.

AUTHOR

Dan Book <dbook@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2016 by Dan Book.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)

SEE ALSO

Mojo::IOLoop::Subprocess, Mojo::IOLoop::Subprocess::Sereal, Sereal