[jira] [Commented] (MESOS-5038) Added a any mechanism for futures

2016-04-07 Thread haosdent (JIRA)

[ 
https://issues.apache.org/jira/browse/MESOS-5038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15231476#comment-15231476
 ] 

haosdent commented on MESOS-5038:
-

Compare with use {{Future any(const std::list>& futures)}}, the 
problem of add mode to {{collect}} is it always return {{list}} although we may 
just want to get single result when use {{ANY}} mode.

> Added a any mechanism for futures
> -
>
> Key: MESOS-5038
> URL: https://issues.apache.org/jira/browse/MESOS-5038
> Project: Mesos
>  Issue Type: Improvement
>  Components: libprocess
>Reporter: haosdent
>Assignee: haosdent
>
> Now we already have {{collect}} and {{await}} mechanisms which would wait for 
> a list of {{Future}}. However, we would like to return immediately if any of 
> the list of {{Future}} complete instead of wait for the whole list finished 
> in {{collect}}. The interface of this any mechanism could be
> {code}
> template 
> Future any(const std::list>& futures);
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (MESOS-5038) Added a any mechanism for futures

2016-04-07 Thread haosdent (JIRA)

[ 
https://issues.apache.org/jira/browse/MESOS-5038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15231474#comment-15231474
 ] 

haosdent commented on MESOS-5038:
-

[~gilbert] I have already changed to use
{code}
Future> collect(
const std::list>& futures,
const collect::Mode& mode);
{code}

May I have your review? Thanks in advance.

> Added a any mechanism for futures
> -
>
> Key: MESOS-5038
> URL: https://issues.apache.org/jira/browse/MESOS-5038
> Project: Mesos
>  Issue Type: Improvement
>  Components: libprocess
>Reporter: haosdent
>Assignee: haosdent
>
> Now we already have {{collect}} and {{await}} mechanisms which would wait for 
> a list of {{Future}}. However, we would like to return immediately if any of 
> the list of {{Future}} complete instead of wait for the whole list finished 
> in {{collect}}. The interface of this any mechanism could be
> {code}
> template 
> Future any(const std::list>& futures);
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (MESOS-5038) Added a any mechanism for futures

2016-04-06 Thread haosdent (JIRA)

[ 
https://issues.apache.org/jira/browse/MESOS-5038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15229577#comment-15229577
 ] 

haosdent commented on MESOS-5038:
-

We could add to await as well. But as you see, 
{code}
Future> collect(
const std::list>& futures,
const collect::Mode& mode);
{code}

{{collect}} return a list of result. In {{ANY}} mode, it only return one result 
in list. I am not sure whether it would become the final proposal. Let's add 
that if we are sure use this way.

> Added a any mechanism for futures
> -
>
> Key: MESOS-5038
> URL: https://issues.apache.org/jira/browse/MESOS-5038
> Project: Mesos
>  Issue Type: Improvement
>  Components: libprocess
>Reporter: haosdent
>Assignee: haosdent
>
> Now we already have {{collect}} and {{await}} mechanisms which would wait for 
> a list of {{Future}}. However, we would like to return immediately if any of 
> the list of {{Future}} complete instead of wait for the whole list finished 
> in {{collect}}. The interface of this any mechanism could be
> {code}
> template 
> Future any(const std::list>& futures);
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (MESOS-5038) Added a any mechanism for futures

2016-04-05 Thread Jay Guo (JIRA)

[ 
https://issues.apache.org/jira/browse/MESOS-5038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15227588#comment-15227588
 ] 

Jay Guo commented on MESOS-5038:


BTW, would it be nice to have an await() that handles futures with a number of 
different types?

> Added a any mechanism for futures
> -
>
> Key: MESOS-5038
> URL: https://issues.apache.org/jira/browse/MESOS-5038
> Project: Mesos
>  Issue Type: Improvement
>  Components: libprocess
>Reporter: haosdent
>Assignee: haosdent
>
> Now we already have {{collect}} and {{await}} mechanisms which would wait for 
> a list of {{Future}}. However, we would like to return immediately if any of 
> the list of {{Future}} complete instead of wait for the whole list finished 
> in {{collect}}. The interface of this any mechanism could be
> {code}
> template 
> Future any(const std::list>& futures);
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (MESOS-5038) Added a any mechanism for futures

2016-04-05 Thread haosdent (JIRA)

[ 
https://issues.apache.org/jira/browse/MESOS-5038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15226697#comment-15226697
 ] 

haosdent commented on MESOS-5038:
-

Thanks for pointing this! I don't know this before. My concern is it doesn't 
return when future failed or discarded.
{code}
  if (promise->future().isPending()) { // No-op if it's discarded.
if (future.isReady()) { // We only set the promise if a future is ready.
  promise->set(future);
}
  }
{code}

> Added a any mechanism for futures
> -
>
> Key: MESOS-5038
> URL: https://issues.apache.org/jira/browse/MESOS-5038
> Project: Mesos
>  Issue Type: Improvement
>  Components: libprocess
>Reporter: haosdent
>Assignee: haosdent
>
> Now we already have {{collect}} and {{await}} mechanisms which would wait for 
> a list of {{Future}}. However, we would like to return immediately if any of 
> the list of {{Future}} complete instead of wait for the whole list finished 
> in {{collect}}. The interface of this any mechanism could be
> {code}
> template 
> Future any(const std::list>& futures);
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (MESOS-5038) Added a any mechanism for futures

2016-04-05 Thread Jie Yu (JIRA)

[ 
https://issues.apache.org/jira/browse/MESOS-5038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15226584#comment-15226584
 ] 

Jie Yu commented on MESOS-5038:
---

Do you know we have a 'select' already in libprocess:
https://github.com/apache/mesos/blob/master/3rdparty/libprocess/include/process/future.hpp#L784



> Added a any mechanism for futures
> -
>
> Key: MESOS-5038
> URL: https://issues.apache.org/jira/browse/MESOS-5038
> Project: Mesos
>  Issue Type: Improvement
>  Components: libprocess
>Reporter: haosdent
>Assignee: haosdent
>
> Now we already have {{collect}} and {{await}} mechanisms which would wait for 
> a list of {{Future}}. However, we would like to return immediately if any of 
> the list of {{Future}} complete instead of wait for the whole list finished 
> in {{collect}}. The interface of this any mechanism could be
> {code}
> template 
> Future any(const std::list>& futures);
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (MESOS-5038) Added a any mechanism for futures

2016-04-05 Thread Gilbert Song (JIRA)

[ 
https://issues.apache.org/jira/browse/MESOS-5038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15226574#comment-15226574
 ] 

Gilbert Song commented on MESOS-5038:
-

Sounds good. For now, the mode with `any` and `all` is enough for use. (maybe 
we can make the mode as an `int` to capture specified number of ready future, 
but that is belong to a rare case and can be done in the future)

> Added a any mechanism for futures
> -
>
> Key: MESOS-5038
> URL: https://issues.apache.org/jira/browse/MESOS-5038
> Project: Mesos
>  Issue Type: Improvement
>  Components: libprocess
>Reporter: haosdent
>Assignee: haosdent
>
> Now we already have {{collect}} and {{await}} mechanisms which would wait for 
> a list of {{Future}}. However, we would like to return immediately if any of 
> the list of {{Future}} complete instead of wait for the whole list finished 
> in {{collect}}. The interface of this any mechanism could be
> {code}
> template 
> Future any(const std::list>& futures);
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (MESOS-5038) Added a any mechanism for futures

2016-04-05 Thread haosdent (JIRA)

[ 
https://issues.apache.org/jira/browse/MESOS-5038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15226542#comment-15226542
 ] 

haosdent commented on MESOS-5038:
-

Probably we could continue to use {{collect}}, but add an additional enum 
parameter(the name of parameter should be {{mode}}). The default {{mode}} is 
{{ALL}} and {{collect}} would wait for all futures. But when we pass {{ANY}} as 
mode, {{collect}} would return directly if any of futures complete. 

> Added a any mechanism for futures
> -
>
> Key: MESOS-5038
> URL: https://issues.apache.org/jira/browse/MESOS-5038
> Project: Mesos
>  Issue Type: Improvement
>  Components: libprocess
>Reporter: haosdent
>Assignee: haosdent
>
> Now we already have {{collect}} and {{await}} mechanisms which would wait for 
> a list of {{Future}}. However, we would like to return immediately if any of 
> the list of {{Future}} complete instead of wait for the whole list finished 
> in {{collect}}. The interface of this any mechanism could be
> {code}
> template 
> Future any(const std::list>& futures);
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (MESOS-5038) Added a any mechanism for futures

2016-04-04 Thread Gilbert Song (JIRA)

[ 
https://issues.apache.org/jira/browse/MESOS-5038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15225735#comment-15225735
 ] 

Gilbert Song commented on MESOS-5038:
-

Thanks [~haosd...@gmail.com], I like this idea, and definitely we need it. 
Thanks for putting this as the first on your patches chain. 

Just want to discuss: `any` sounds good to me, but will we possibly have a more 
accurate name for this mechanism?

> Added a any mechanism for futures
> -
>
> Key: MESOS-5038
> URL: https://issues.apache.org/jira/browse/MESOS-5038
> Project: Mesos
>  Issue Type: Improvement
>  Components: libprocess
>Reporter: haosdent
>Assignee: haosdent
>
> Now we already have {{collect}} and {{await}} mechanisms which would wait for 
> a list of {{Future}}. However, we would like to return immediately if any of 
> the list of {{Future}} complete instead of wait for the whole list finished 
> in {{collect}}. The interface of this any mechanism could be
> {code}
> template 
> Future any(const std::list>& futures);
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (MESOS-5038) Added a any mechanism for futures

2016-03-27 Thread haosdent (JIRA)

[ 
https://issues.apache.org/jira/browse/MESOS-5038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15213869#comment-15213869
 ] 

haosdent commented on MESOS-5038:
-

As you see, we use {{any}} in https://reviews.apache.org/r/45085/diff/

{code}
  any(futures).onAny(defer(PID(this),
  &CgroupsIsolatorProcess::__prepare,
  containerId,
  lambda::_1));
{code}

> Added a any mechanism for futures
> -
>
> Key: MESOS-5038
> URL: https://issues.apache.org/jira/browse/MESOS-5038
> Project: Mesos
>  Issue Type: Improvement
>  Components: libprocess
>Reporter: haosdent
>Assignee: haosdent
>
> Now we already have {{collect}} and {{await}} mechanisms which would wait for 
> a list of {{Future}}. However, we would like to return immediately if any of 
> the list of {{Future}} complete instead of wait for the whole list finished 
> in {{collect}}. The interface of this any mechanism could be
> {code}
> template 
> Future any(const std::list>& futures);
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (MESOS-5038) Added a any mechanism for futures

2016-03-27 Thread Jay Guo (JIRA)

[ 
https://issues.apache.org/jira/browse/MESOS-5038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15213864#comment-15213864
 ] 

Jay Guo commented on MESOS-5038:


[~haosd...@gmail.com] Do you mind giving an example where we may use this in 
current codebase?

> Added a any mechanism for futures
> -
>
> Key: MESOS-5038
> URL: https://issues.apache.org/jira/browse/MESOS-5038
> Project: Mesos
>  Issue Type: Improvement
>  Components: libprocess
>Reporter: haosdent
>Assignee: haosdent
>
> Now we already have {{collect}} and {{await}} mechanisms which would wait for 
> a list of {{Future}}. However, we would like to return immediately if any of 
> the list of {{Future}} complete instead of wait for the whole list finished 
> in {{collect}}. The interface of this any mechanism could be
> {code}
> template 
> Future any(const std::list>& futures);
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (MESOS-5038) Added a any mechanism for futures

2016-03-27 Thread haosdent (JIRA)

[ 
https://issues.apache.org/jira/browse/MESOS-5038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15213856#comment-15213856
 ] 

haosdent commented on MESOS-5038:
-

[~guoger] For example, you wait for a list of futures. You want to continue if 
any of them status becomes ready.

> Added a any mechanism for futures
> -
>
> Key: MESOS-5038
> URL: https://issues.apache.org/jira/browse/MESOS-5038
> Project: Mesos
>  Issue Type: Improvement
>  Components: libprocess
>Reporter: haosdent
>Assignee: haosdent
>
> Now we already have {{collect}} and {{await}} mechanisms which would wait for 
> a list of {{Future}}. However, we would like to return immediately if any of 
> the list of {{Future}} complete instead of wait for the whole list finished 
> in {{collect}}. The interface of this any mechanism could be
> {code}
> template 
> Future any(const std::list>& futures);
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (MESOS-5038) Added a any mechanism for futures

2016-03-27 Thread Jay Guo (JIRA)

[ 
https://issues.apache.org/jira/browse/MESOS-5038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15213808#comment-15213808
 ] 

Jay Guo commented on MESOS-5038:


what's the use case of this one?

> Added a any mechanism for futures
> -
>
> Key: MESOS-5038
> URL: https://issues.apache.org/jira/browse/MESOS-5038
> Project: Mesos
>  Issue Type: Improvement
>  Components: libprocess
>Reporter: haosdent
>Assignee: haosdent
>
> Now we already have {{collect}} and {{await}} mechanisms which would wait for 
> a list of {{Future}}. However, we would like to return immediately if any of 
> the list of {{Future}} complete instead of wait for the whole list finished 
> in {{collect}}. The interface of this any mechanism could be
> {code}
> template 
> Future any(const std::list>& futures);
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)