Commit 0a7da733 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 362dbf6e
......@@ -41,6 +41,8 @@ cdef extern from "wcfs_misc.h" nogil:
cdef extern from "wcfs_watchlink.h" nogil:
cppclass WatchLink:
error close()
#error recvReq(ctx, PinReq *rx_into)
pair[string, error] sendReq(ctx, const string &req)
ctypedef WatchLink *pWatchLink # https://github.com/cython/cython/issues/534
......@@ -83,6 +85,20 @@ cdef class PyWatchLink:
raise RuntimeError(err.Error()) # XXX exc class?
# XXX recvReq
def sendReq(PyWatchLink pywlink, ctx, string req): # -> reply(string)
with nogil:
_ = wlink_sendReq_pyexc(pywlink.wlink, ctx, req)
reply = _.first
err = _.second
if err != nil:
raise RuntimeError(err.Error()) # XXX -> Xpy(err) ? pyraiseIf(err) ?
return reply
cdef class PyPinReq:
pass
......@@ -93,8 +109,11 @@ cdef class PyPinReq:
cdef nogil:
pair[pWatchLink, error] wcfs_openwatch_pyexc(WCFS *wcfs) except +topyexc:
return wcfs._openwatch()
error wlink_close_pyexc(WatchLink *wlink) except +topyexc:
return wlink.close()
pair[pWatchLink, error] wcfs_openwatch_pyexc(WCFS *wcfs) except +topyexc:
return wcfs._openwatch()
pair[string, error] wlink_sendReq_pyexc(WatchLink *wlink, ctx, const string &req) except +topyexc:
return wlink.sendReq(ctx, req)
......@@ -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(context::Context *ctx, const string &req) {
pair<string, error> WatchLink::sendReq(context::Context *ctx, const string &req) {
WatchLink *wlink = this;
// XXX err ctx
......@@ -224,11 +224,11 @@ tuple<string, error> WatchLink::sendReq(context::Context *ctx, const string &req
rxq.recvs(&rx), // 1
});
if (_ == 0)
return make_tuple("", ctx->err());
return make_pair("", ctx->err());
// XXX check for EOF
string reply = rx.to_string();
return make_tuple(reply, nil);
return make_pair(reply, nil);
}
tuple</*rxq*/chan<rxPkt>, error> WatchLink::_sendReq(context::Context *ctx, const string &req) {
......
......@@ -88,7 +88,7 @@ public:
friend pair<WatchLink*, error> WCFS::_openwatch();
error close();
error recvReq(context::Context *ctx, PinReq *rx_into);
tuple<string, error> sendReq(context::Context *ctx, const string &req);
pair<string, error> sendReq(context::Context *ctx, const string &req);
private:
void _closeTX();
......
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