Commit 049b11af authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent edbe92f7
......@@ -230,6 +230,30 @@ vector<string> split(const string &s, char sep) {
} // strings::
// context::
namespace context {
const error canceled = fmt::errorf("context canceled");
const error deadlineExceeded = fmt::errorf("deadline exceeded");
struct _Background : Context {
chan<structZ> done() {
return nil;
}
error err() {
return nil;
}
};
static _Background _bg;
Context* background() {
return &_bg; // NOTE nil is not valid in C++ (IContext* also carries vtab ptr)
}
} // context::
// xstrconv:: (strconv-like)
namespace xstrconv {
......
......@@ -163,35 +163,20 @@ vector<string> split(const string &s, char sep);
} // strings::
// XXX ok?
struct IContext {
virtual chan<structZ> done() = 0;
virtual error err() = 0;
};
// context::
namespace context {
struct _Background : IContext {
chan<structZ> done() {
return nil;
}
error err() {
return nil;
}
struct Context {
virtual chan<structZ> done() = 0;
virtual error err() = 0;
};
static _Background _bg;
// XXX doc
IContext* background() {
return &_bg; // NOTE nil is not valid in C++ (IContext* also carries vtab ptr)
}
Context* background();
// XXX doc
const error canceled = fmt::errorf("context canceled");
// XXX deadline exceeded?
extern const error canceled;
extern const error deadlineExceeded;
} // context::
......
......@@ -71,7 +71,7 @@ public:
error resync(zodb::Tid at);
private:
void _pinner(IContext *ctx);
void _pinner(context::Context *ctx);
void _pin1(PinReq *req);
};
......@@ -172,7 +172,7 @@ error Conn::close() { // XXX error -> void?
}
// _pinner receives pin messages from wcfs and adjusts wconn mappings.
void Conn::_pinner(IContext *ctx) {
void Conn::_pinner(context::Context *ctx) {
Conn &wconn = *this;
// XXX panic/exc -> log.CRITICAL
......
......@@ -97,7 +97,7 @@ error WatchLink::close() {
}
// _serveRX receives messages from ._f and dispatches them according to streamID.
error WatchLink::_serveRX(IContext *ctx) { // XXX error -> where ?
error WatchLink::_serveRX(context::Context *ctx) { // XXX error -> where ?
WatchLink& wlink = *this;
// when finishing - wakeup everyone waiting for rx
......@@ -209,7 +209,7 @@ error WatchLink::_write(const string &pkt) {
// sendReq sends client -> server request and returns server reply.
// XXX -> reply | None when EOF
tuple<string, error> WatchLink::sendReq(IContext *ctx, const string &req) {
tuple<string, error> WatchLink::sendReq(context::Context *ctx, const string &req) {
WatchLink *wlink = this;
// XXX err ctx
......@@ -231,7 +231,7 @@ tuple<string, error> WatchLink::sendReq(IContext *ctx, const string &req) {
return make_tuple(reply, nil);
}
tuple</*rxq*/chan<rxPkt>, error> WatchLink::_sendReq(IContext *ctx, const string &req) {
tuple</*rxq*/chan<rxPkt>, error> WatchLink::_sendReq(context::Context *ctx, const string &req) {
WatchLink *wlink = this;
// XXX err ctx?
......@@ -269,7 +269,7 @@ tuple</*rxq*/chan<rxPkt>, error> WatchLink::_sendReq(IContext *ctx, const string
// recvReq receives client <- server request.
static error _parsePinReq(PinReq *pin, const rxPkt *pkt);
error WatchLink::recvReq(IContext *ctx, PinReq *prx) {
error WatchLink::recvReq(context::Context *ctx, PinReq *prx) {
WatchLink& wlink = *this;
// XXX err ctx?
......
......@@ -87,16 +87,16 @@ class WatchLink {
public:
friend tuple<WatchLink*, error> WCFS::_openwatch();
error close();
error recvReq(IContext *ctx, PinReq *rx_into);
tuple<string, error> sendReq(IContext *ctx, const string &req);
error recvReq(context::Context *ctx, PinReq *rx_into);
tuple<string, error> sendReq(context::Context *ctx, const string &req);
private:
void _closeTX();
error _serveRX(IContext *ctx);
error _serveRX(context::Context *ctx);
tuple<string, error> _readline();
error _send(StreamID stream, const string &msg);
error _write(const string &pkt);
tuple<chan<rxPkt>, error> _sendReq(IContext *ctx, const string &req);
tuple<chan<rxPkt>, error> _sendReq(context::Context *ctx, const string &req);
};
// PinReq represents 1 server-initiated wcfs pin request received over /head/watch link.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment