Remove indirection in LoadBalancedReply serialization

This commit is contained in:
Andrew Noyes 2019-07-31 11:35:53 -07:00
parent bd3cfb12eb
commit 0569df00f6
2 changed files with 4 additions and 8 deletions

View File

@ -119,7 +119,7 @@ struct GetValueReply : public LoadBalancedReply {
template <class Ar>
void serialize( Ar& ar ) {
serializer(ar, *(LoadBalancedReply*)this, value);
serializer(ar, penalty, error, value);
}
};
@ -167,7 +167,7 @@ struct GetKeyValuesReply : public LoadBalancedReply {
template <class Ar>
void serialize( Ar& ar ) {
serializer(ar, *(LoadBalancedReply*)this, data, version, more, arena);
serializer(ar, penalty, error, data, version, more, arena);
}
};
@ -198,7 +198,7 @@ struct GetKeyReply : public LoadBalancedReply {
template <class Ar>
void serialize( Ar& ar ) {
serializer(ar, *(LoadBalancedReply*)this, sel);
serializer(ar, penalty, error, sel);
}
};

View File

@ -66,15 +66,11 @@ struct ModelHolder : NonCopyable, public ReferenceCounted<ModelHolder> {
};
// Subclasses must initialize all members in their default constructors
// Subclasses must serialize all members
struct LoadBalancedReply {
double penalty;
Optional<Error> error;
LoadBalancedReply() : penalty(1.0) {}
template <class Ar>
void serialize(Ar &ar) {
serializer(ar, penalty, error);
}
};
Optional<LoadBalancedReply> getLoadBalancedReply(LoadBalancedReply *reply);