コード例 #1
0
 template<typename data_type> bool fetch( data_type& t, std::function<bool( std::istream&, data_type& )> deserializer = &data_type::restore ) {
     std::vector< adfs::char_t > iobuf( size() );
     if ( read( iobuf.size(), iobuf.data() ) == iobuf.size() ) {
         boost::iostreams::basic_array_source< char > device( iobuf.data(), iobuf.size() );
         boost::iostreams::stream< boost::iostreams::basic_array_source< char > > st( device );
         return deserializer( st, t );
     }
     return false;
 }
コード例 #2
0
ファイル: IOBuf.cpp プロジェクト: JingangLi/folly
unique_ptr<IOBuf> IOBuf::cloneOne() const {
  if (sharedInfo_) {
    flags_ |= kFlagMaybeShared;
  }
  unique_ptr<IOBuf> iobuf(new IOBuf(static_cast<ExtBufTypeEnum>(type_),
                                    flags_, buf_, capacity_,
                                    data_, length_,
                                    sharedInfo_));
  if (sharedInfo_) {
    sharedInfo_->refcount.fetch_add(1, std::memory_order_acq_rel);
  }
  return iobuf;
}