--- AnyEvent-Fork-RPC/RPC.pm 2013/11/20 15:26:56 1.34 +++ AnyEvent-Fork-RPC/RPC.pm 2013/11/20 16:17:22 1.35 @@ -527,6 +527,30 @@ sub { unpack "(w/a*)*", shift } ) +=item json - C<$AnyEvent::Fork::RPC::CBOR_XS_SERIALISER> + +This serialiser creates CBOR::XS arrays - you have to make sure the +L module is installed for this serialiser to work. It can be +beneficial for sharing when you preload the L module in a template +process. + +L is about as fast as the octet string serialiser, but supports +complex data structures (similar to JSON) and is faster than any of the +other serialisers. If you have the L module available, it's the +best choice. + +Note that the CBOR::XS module supports some extensions to encode cyclic +and self-referencing data structures, which are not enabled. You need to +write your own serialiser to take advantage of these. + +Implementation: + + use CBOR::XS (); + ( + sub { CBOR::XS::encode_cbor \@_ }, + sub { @{ CBOR::XS::decode_cbor shift } } + ) + =item json - C<$AnyEvent::Fork::RPC::JSON_SERIALISER> This serialiser creates JSON arrays - you have to make sure the L @@ -585,7 +609,8 @@ =cut our $STRING_SERIALISER = '(sub { pack "(w/a*)*", @_ }, sub { unpack "(w/a*)*", shift })'; -our $JSON_SERIALISER = 'use JSON (); (sub { JSON::encode_json \@_ }, sub { @{ JSON::decode_json shift } })'; +our $CBOR_XS_SERIALISER = 'use CBOR::XS (); (sub { CBOR::XS::encode_cbor \@_ }, sub { @{ CBOR::XS::decode_cbor shift } })'; +our $JSON_SERIALISER = 'use JSON (); (sub { JSON::encode_json \@_ }, sub { @{ JSON::decode_json shift } })'; our $STORABLE_SERIALISER = 'use Storable (); (sub { Storable::freeze \@_ }, sub { @{ Storable::thaw shift } })'; our $NSTORABLE_SERIALISER = 'use Storable (); (sub { Storable::nfreeze \@_ }, sub { @{ Storable::thaw shift } })';