mesos-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benjamin Hindman <b...@berkeley.edu>
Subject Re: Review Request 54110: Added `process::loop` abstraction.
Date Tue, 29 Nov 2016 02:47:28 GMT

-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/54110/#review157168
-----------------------------------------------------------




3rdparty/libprocess/include/process/loop.hpp (line 55)
<https://reviews.apache.org/r/54110/#comment227603>

    return iterate()
      .then([](T t) {
        return body(t)
          .then([](bool condition) {
            if (condition) {
              return loop();
            } else {
              return Nothing();
            }
          });
      });
    
    Future<T> t = iterate();
    while (t.isReady()) {
      Future<bool> condition = body(t.get());
      if (condition.isReady()) {
        t = iterate();
        continue;
      } else {
        condition
          .onAny(defer(...));
        break;
      }
    }
    
    t.onAny(defer(...));
    
    return iterate()
      .then(defer(pid, [](T t) {
        return body(t)
          .then(defer(pid, [](bool condition) {
            if (condition) {
              return loop();
            } else {
              return Nothing();
            }
          }));
      }));
    
    loop(
        []() { return io::read(fd, data, size); },
        [](size_t length) {
          if (length == 0) {
            return false;
          }
          buffer.append(data, length);
        })
        .then([]() {
          return buffer.str();
        });
    
    Promise<T> promise;
    
    []() {
      .onAny([]() { if (!condition) { promise.set(value); }})
    });
    
    return promise.future();



3rdparty/libprocess/include/process/loop.hpp (line 99)
<https://reviews.apache.org/r/54110/#comment227627>

    We'll do a "managed" spawn here instead so that we don't need to `wait` or `delete` we
just have to `terminate`.



3rdparty/libprocess/include/process/loop.hpp (line 124)
<https://reviews.apache.org/r/54110/#comment227639>

    void start()
    {
      promise.future()
        .onDiscard(...);
      run();
    }



3rdparty/libprocess/include/process/loop.hpp (line 129)
<https://reviews.apache.org/r/54110/#comment227630>

    s/future/next/



3rdparty/libprocess/include/process/loop.hpp (line 137)
<https://reviews.apache.org/r/54110/#comment227637>

    Future<bool> condition = true;
    
    while (condition.get()) {
      Future<T> next = discard_if_necessary(iterate());
      if (next.isReady()) {
        condition = discard_if_necessary(body(next.get()));
        if (condition.isReady()) {
          continue;
        } else {
          block_on_condition();
          return;
        }
      } else {
        block_on_next();
        return;
      }
    }
    
    promise.set(Nothing()); // All done!
    
    void block_on_next()
    {
        next
          .onAny([]() {
              if (next.isReady()) {
                condition = discard_if_necessary(body(next.get()));
                if (condition.isReady()) {
                  run(loop);
                } else {
                  block_on_condition();
                }
              } else if (isDiscarded) {
              } else if (isFailed) {
              }
          });
    
    }
    
    void block_on_condition()
    {
          condition
            .onAny([]() {
              if (condition.isReady()) {
                if (condition.get()) {
                  run(loop);
                } else {
                  promise.set(Nothing());
                }
              } else if (isDiscarded) {
              } else if (isFailed) {
              }
            });
    }



3rdparty/libprocess/include/process/loop.hpp (line 204)
<https://reviews.apache.org/r/54110/#comment227638>

    dispatch(pid, [=]() {
      loop->start();
    });



3rdparty/libprocess/include/process/loop.hpp (lines 206 - 208)
<https://reviews.apache.org/r/54110/#comment227629>

    Add a comment which explains why we need to explicitly do the discard here, as well as
in all the cases above.


- Benjamin Hindman


On Nov. 28, 2016, 6:33 p.m., Benjamin Hindman wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/54110/
> -----------------------------------------------------------
> 
> (Updated Nov. 28, 2016, 6:33 p.m.)
> 
> 
> Review request for mesos, Benjamin Mahler and Michael Park.
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Added `process::loop` abstraction.
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/Makefile.am 71319891a451bd1d565210dcce2fb61fc69e1f61 
>   3rdparty/libprocess/include/process/loop.hpp PRE-CREATION 
>   3rdparty/libprocess/src/tests/loop_tests.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/54110/diff/
> 
> 
> Testing
> -------
> 
> make check
> 
> 
> Thanks,
> 
> Benjamin Hindman
> 
>


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message