Commit 294a9d5d authored by Thai Nguyen's avatar Thai Nguyen
Browse files

Enhance Performance for Client and P2P

parent d66db50f
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ class ByteStreamInterface {
    virtual bool Read(void *buf, size_t n) = 0;
    virtual bool Write(const void *buf, size_t n) = 0;
    virtual IncomingValueInterface *ReadValue(size_t n) = 0;
    virtual bool WriteValue(const OutgoingValueInterface &value) = 0;
    virtual bool WriteValue(const OutgoingValueInterface &value, int* err) = 0;
};

class PlainByteStream : public ByteStreamInterface {
@@ -44,7 +44,7 @@ class PlainByteStream : public ByteStreamInterface {
    bool Read(void *buf, size_t n);
    bool Write(const void *buf, size_t n);
    IncomingValueInterface *ReadValue(size_t n);
    bool WriteValue(const OutgoingValueInterface &value);
    bool WriteValue(const OutgoingValueInterface &value, int* err);

    private:
    int fd_;
@@ -59,7 +59,7 @@ class SslByteStream : public ByteStreamInterface {
    bool Read(void *buf, size_t n);
    bool Write(const void *buf, size_t n);
    IncomingValueInterface *ReadValue(size_t n);
    bool WriteValue(const OutgoingValueInterface &value);
    bool WriteValue(const OutgoingValueInterface &value, int* err);

    private:
    SSL *ssl_;
+4 −4
Original line number Diff line number Diff line
@@ -41,8 +41,8 @@ class MessageStreamInterface {
    virtual ~MessageStreamInterface() {}
    virtual MessageStreamReadStatus ReadMessage(::google::protobuf::Message *message,
        IncomingValueInterface** value) = 0;
    virtual bool WriteMessage(const ::google::protobuf::Message &message,
        const OutgoingValueInterface& value) = 0;
    virtual int WriteMessage(const ::google::protobuf::Message &message,
        const OutgoingValueInterface& value, int* err) = 0;
};

class MessageStream : public MessageStreamInterface {
@@ -51,8 +51,8 @@ class MessageStream : public MessageStreamInterface {
    ~MessageStream();
    MessageStreamReadStatus ReadMessage(::google::protobuf::Message *message,
        IncomingValueInterface** value);
    bool WriteMessage(const ::google::protobuf::Message &message,
        const OutgoingValueInterface& value);
    int WriteMessage(const ::google::protobuf::Message &message,
        const OutgoingValueInterface& value, int* err);

    private:
    bool ReadHeader(uint32_t *message_size, uint32_t *value_size);
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ class MockMessageStream : public MessageStreamInterface {
    MockMessageStream() {}
    MOCK_METHOD2(ReadMessage, MessageStreamReadStatus(::google::protobuf::Message *message,
        IncomingValueInterface** value));
    MOCK_METHOD2(WriteMessage, bool(const ::google::protobuf::Message &message,
    MOCK_METHOD2(WriteMessage, int(const ::google::protobuf::Message &message,
        const OutgoingValueInterface& value));
    MOCK_METHOD0(BytesRead, int64_t());
    MOCK_METHOD0(BytesWritten, int64_t());
+4 −4
Original line number Diff line number Diff line
@@ -31,16 +31,16 @@ class OutgoingValueInterface {
    public:
    virtual ~OutgoingValueInterface() {}
    virtual size_t size() const = 0;
    virtual bool TransferToSocket(int fd) const = 0;
    virtual bool ToString(std::string *result) const = 0;
    virtual bool TransferToSocket(int fd, int* err) const = 0;
    virtual bool ToString(std::string *result, int* err) const = 0;
};

class OutgoingStringValue : public OutgoingValueInterface {
    public:
    explicit OutgoingStringValue(const std::string &s);
    size_t size() const;
    bool TransferToSocket(int fd) const;
    bool ToString(std::string *result) const;
    bool TransferToSocket(int fd, int* err) const;
    bool ToString(std::string *result, int* err) const;

    private:
    const std::string s_;
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ namespace kinetic {
class ReaderWriter {
    public:
    explicit ReaderWriter(int fd);
    bool Read(void *buf, size_t n);
    bool Read(void *buf, size_t n, int* err);
    bool Write(const void *buf, size_t n);

    private:
Loading