comparison vamp-client/SynchronousTransport.h @ 126:2004ec2b653e

Ensure we read right up to end of buffered data after server exits; adjust waiting schedule on Windows (where waitForReadyRead is far too wasteful of sleep time)
author Chris Cannam <c.cannam@qmul.ac.uk>
date Fri, 28 Oct 2016 14:31:58 +0100
parents 56e537a7bb99
children 3dcf0394971d
comparison
equal deleted inserted replaced
125:ea06fae1567c 126:2004ec2b653e
60 class SynchronousTransport // interface 60 class SynchronousTransport // interface
61 { 61 {
62 public: 62 public:
63 virtual ~SynchronousTransport() = default; 63 virtual ~SynchronousTransport() = default;
64 64
65 //!!! I do not take ownership 65 /**
66 * Set a completeness checker object. The caller retains ownership
67 * of the checker and must ensure its lifespan outlives the transport.
68 */
66 virtual void setCompletenessChecker(MessageCompletenessChecker *) = 0; 69 virtual void setCompletenessChecker(MessageCompletenessChecker *) = 0;
67
68 //!!! how to handle errors -- exception or return value? often an
69 //!!! error (e.g. server has exited) may mean the transport can no
70 //!!! longer be used at all
71 virtual std::vector<char> call(const char *data, size_t bytes) = 0;
72 70
71 /**
72 * Make a synchronous call, passing a serialised request in the data array
73 * of length bytes, and return the result.
74 *
75 * The slow flag is a hint that the recipient may take longer than usual
76 * to process this request and so the caller may wish to be more relaxed
77 * about idling to wait for the reply. (This shouldn't make any difference
78 * with a sensible blocking network API, but you never know...)
79 *
80 * May throw ServerCrashed if the server endpoint disappeared during the
81 * call. Throws std::logic_error if isOK() is not true at the time of
82 * calling, so check that before you call.
83 */
84 virtual std::vector<char> call(const char *data, size_t bytes, bool slow) = 0;
85
86 /**
87 * Check whether the transport was initialised correctly and is working.
88 * This will return false if the endpoint could not be initialised or
89 * the endpoint service has crashed or become unavailable. Always check
90 * this before using call().
91 */
73 virtual bool isOK() const = 0; 92 virtual bool isOK() const = 0;
74 }; 93 };
75 94
76 } 95 }
77 } 96 }