--- deliantra/server/lib/cf.pm 2016/11/18 20:55:00 1.621 +++ deliantra/server/lib/cf.pm 2016/11/23 06:05:33 1.622 @@ -59,6 +59,7 @@ use Data::Dumper; use Fcntl; use YAML::XS (); +use CBOR::XS (); use IO::AIO (); use Compress::LZF; use Digest::MD5 (); @@ -466,6 +467,20 @@ fork_call { YAML::XS::Load $_[0] } @_ } +=item $scalar = cf::decode_cbor $scalar + +Same as CBOR::XS::decode_cbor, but takes server ticks into account, so +blocks. For small amounts of data, C is the better +alternative. + +=cut + +sub decode_cbor($) { + # we assume 10mb/s minimum decoding speed (on a ~2ghz machine) + cf::get_slot +(length $_[0]) / 10_000_000, 0, "decode_cbor"; + CBOR::XS::decode_cbor $_[0] +} + =item $scalar = cf::unlzf $scalar Same as Compress::LZF::compress, but takes server ticks into account, so