3rdparty / eventuals-grpc

C++ asynchronous interface for gRPC based on https://github.com/3rdparty/eventuals.
Apache License 2.0
20 stars 5 forks source link

Implement `Pipe` class #39

Closed ArthurBandaryk closed 3 years ago

ArthurBandaryk commented 3 years ago

Instead of Endpoint class we will use the Pipe class! This class will be inherited from Synchronizable class (eventuals/lock.h). The future implementation will be like the following one:

template<typename T>
class Pipe :  public Synchronizable {
public:
      auto Write( T&& value){
        return Synchronized(Lambda([](){
          // store this value in a deque
          ...
          notify_();
        }));    
      }

      auto Read(){
        return Repeat(
               Synchronized(
                   Wait([](auto notify){
                      ...
                    })));
      }
      auto Close(){
         return Synchronized(Then([]() {
           is_closed = true;
           notify_();
         }));
      }
private:
  Callback<> notify_ = []() {};
  std::deque<T> values_;
  bool is_closed_ = false;
}
benh commented 3 years ago

Hey @ArthurBandaryk, please move this issue to eventuals not eventuals-grpc. We'll use it here but it should get implemented there, thanks!