luliyucoordinate opened a new issue, #1907:
URL: https://github.com/apache/incubator-brpc/issues/1907

   
   我有一段内存想要自己管理或者上层系统管理,例如
   
   ```c++
   static void NoOpDeleter(void *) {}
   class EchoServiceImpl : public EchoService {
   public:
     EchoServiceImpl() {};
     virtual ~EchoServiceImpl() {};
     virtual void Echo(google::protobuf::RpcController* cntl_base,
                       const EchoRequest* request,
                       EchoResponse* response,
                       google::protobuf::Closure* done) {
       std::vector<int> a;
       {
         brpc::ClosureGuard done_guard(done);
         brpc::Controller* cntl =
                   static_cast<brpc::Controller*>(cntl_base);
         a.resize(dim);
         //... a do some calc
         butil::IOBuf &buf = cntl.request_attachment();
         buf.append_user_data(a.data(), a.size() * sizeof(int), NoOpDeleter);
       }
     }
   }
   ```
   
   我的理解是done->Run()过程中,done->Run()是阻塞的,数据`a`会发送结束再出括号再析构a,但是我实际操作发现结果是不正确的。
   
   所以我想问一下如果采用NoOpDeleter这样方式手动管理内存的生命周期,这块内存的生命周期需要存活多久才能保证发送的数据安全。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to