ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-Fork-RPC/RPC.pm
(Generate patch)

Comparing AnyEvent-Fork-RPC/RPC.pm (file contents):
Revision 1.34 by root, Wed Nov 20 15:26:56 2013 UTC vs.
Revision 1.35 by root, Wed Nov 20 16:17:22 2013 UTC

525 ( 525 (
526 sub { pack "(w/a*)*", @_ }, 526 sub { pack "(w/a*)*", @_ },
527 sub { unpack "(w/a*)*", shift } 527 sub { unpack "(w/a*)*", shift }
528 ) 528 )
529 529
530=item json - C<$AnyEvent::Fork::RPC::CBOR_XS_SERIALISER>
531
532This serialiser creates CBOR::XS arrays - you have to make sure the
533L<CBOR::XS> module is installed for this serialiser to work. It can be
534beneficial for sharing when you preload the L<CBOR::XS> module in a template
535process.
536
537L<CBOR::XS> is about as fast as the octet string serialiser, but supports
538complex data structures (similar to JSON) and is faster than any of the
539other serialisers. If you have the L<CBOR::XS> module available, it's the
540best choice.
541
542Note that the CBOR::XS module supports some extensions to encode cyclic
543and self-referencing data structures, which are not enabled. You need to
544write your own serialiser to take advantage of these.
545
546Implementation:
547
548 use CBOR::XS ();
549 (
550 sub { CBOR::XS::encode_cbor \@_ },
551 sub { @{ CBOR::XS::decode_cbor shift } }
552 )
553
530=item json - C<$AnyEvent::Fork::RPC::JSON_SERIALISER> 554=item json - C<$AnyEvent::Fork::RPC::JSON_SERIALISER>
531 555
532This serialiser creates JSON arrays - you have to make sure the L<JSON> 556This serialiser creates JSON arrays - you have to make sure the L<JSON>
533module is installed for this serialiser to work. It can be beneficial for 557module is installed for this serialiser to work. It can be beneficial for
534sharing when you preload the L<JSON> module in a template process. 558sharing when you preload the L<JSON> module in a template process.
583examples. 607examples.
584 608
585=cut 609=cut
586 610
587our $STRING_SERIALISER = '(sub { pack "(w/a*)*", @_ }, sub { unpack "(w/a*)*", shift })'; 611our $STRING_SERIALISER = '(sub { pack "(w/a*)*", @_ }, sub { unpack "(w/a*)*", shift })';
612our $CBOR_XS_SERIALISER = 'use CBOR::XS (); (sub { CBOR::XS::encode_cbor \@_ }, sub { @{ CBOR::XS::decode_cbor shift } })';
588our $JSON_SERIALISER = 'use JSON (); (sub { JSON::encode_json \@_ }, sub { @{ JSON::decode_json shift } })'; 613our $JSON_SERIALISER = 'use JSON (); (sub { JSON::encode_json \@_ }, sub { @{ JSON::decode_json shift } })';
589our $STORABLE_SERIALISER = 'use Storable (); (sub { Storable::freeze \@_ }, sub { @{ Storable::thaw shift } })'; 614our $STORABLE_SERIALISER = 'use Storable (); (sub { Storable::freeze \@_ }, sub { @{ Storable::thaw shift } })';
590our $NSTORABLE_SERIALISER = 'use Storable (); (sub { Storable::nfreeze \@_ }, sub { @{ Storable::thaw shift } })'; 615our $NSTORABLE_SERIALISER = 'use Storable (); (sub { Storable::nfreeze \@_ }, sub { @{ Storable::thaw shift } })';
591 616
592sub run { 617sub run {
593 my ($self, $function, %arg) = @_; 618 my ($self, $function, %arg) = @_;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines