server: op->error() dispatch
Avoid blocking in error()
This commit is contained in:
@@ -30,6 +30,7 @@ public:
|
||||
//! @throws std::runtime_error if the client pvRequest() field mask does not select any fields of prototype.
|
||||
virtual void connect(const Value& prototype) =0;
|
||||
//! Indicate that this operation can not be setup
|
||||
//! @since UNRELEASED Does not block
|
||||
virtual void error(const std::string& msg) =0;
|
||||
|
||||
ConnectOp(const std::string& name,
|
||||
@@ -145,6 +146,7 @@ public:
|
||||
virtual std::unique_ptr<MonitorControlOp> connect(const Value& prototype) =0;
|
||||
|
||||
//! Indicate that this operation can not be setup
|
||||
//! @since UNRELEASED Does not block
|
||||
virtual void error(const std::string& msg) =0;
|
||||
|
||||
MonitorSetupOp(const std::string& name,
|
||||
|
||||
@@ -94,6 +94,7 @@ struct PVXS_API ExecOp : public OpBase {
|
||||
//! Issue a reply with data. For a GET or RPC (or PUT/Get)
|
||||
virtual void reply(const Value& val) =0;
|
||||
//! Indicate the request has resulted in an error.
|
||||
//! @since UNRELEASED Does not block
|
||||
virtual void error(const std::string& msg) =0;
|
||||
|
||||
//! Callback invoked if the peer cancels the operation before reply() or error() is called.
|
||||
|
||||
+6
-3
@@ -203,7 +203,8 @@ struct ServerGPRConnect : public server::ConnectOp
|
||||
auto serv = server.lock();
|
||||
if(!serv)
|
||||
return;
|
||||
serv->acceptor_loop.call([this, &msg](){
|
||||
auto op(this->op);
|
||||
serv->acceptor_loop.dispatch([op, msg](){
|
||||
if(auto oper = op.lock()) {
|
||||
if(oper->state==ServerOp::Creating)
|
||||
oper->doReply(Value(), msg);
|
||||
@@ -273,7 +274,8 @@ struct ServerGPRExec : public server::ExecOp
|
||||
auto serv = server.lock();
|
||||
if(!serv)
|
||||
return;
|
||||
serv->acceptor_loop.call([this, &val](){
|
||||
auto op(this->op);
|
||||
serv->acceptor_loop.dispatch([op, val](){
|
||||
if(auto oper = op.lock()) {
|
||||
oper->doReply(val, std::string());
|
||||
}
|
||||
@@ -287,7 +289,8 @@ struct ServerGPRExec : public server::ExecOp
|
||||
auto serv = server.lock();
|
||||
if(!serv)
|
||||
return;
|
||||
serv->acceptor_loop.call([this, &msg](){
|
||||
auto op(this->op);
|
||||
serv->acceptor_loop.dispatch([op, msg](){
|
||||
if(auto oper = op.lock()) {
|
||||
oper->doReply(Value(), msg);
|
||||
}
|
||||
|
||||
+3
-2
@@ -399,10 +399,11 @@ struct ServerMonitorSetup : public server::MonitorSetupOp
|
||||
auto serv = server.lock();
|
||||
if(!serv)
|
||||
return;
|
||||
serv->acceptor_loop.call([this, &msg](){
|
||||
auto op(this->op);
|
||||
serv->acceptor_loop.dispatch([op, msg]() mutable {
|
||||
if(auto oper = op.lock()) {
|
||||
if(oper->state==ServerOp::Creating) {
|
||||
oper->msg = msg;
|
||||
oper->msg = std::move(msg);
|
||||
oper->doReply();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user