> On July 17, 2015, 1:36 a.m., Jie Yu wrote:
> > src/slave/containerizer/mesos/containerizer.cpp, line 630
> > <https://reviews.apache.org/r/34137/diff/3/?file=1009143#file1009143line630>
> >
> >     Hum, looks like a bug since, for example, slaveId is a reference and 
> > will be invalid when the lambda is called. In general, I think we should 
> > avoid using [=] for lambdas because its dangeous!
> >     
> >     I would prefer we resort to our old style defer style (e.g., introduce 
> > `_provision`).
> 
> Jiang Yan Xu wrote:
>     [=] captures slaveId by value (copy) so it won't be invalid?
>     
>     But after when to use lambdas, I think this is a good point and we should 
> establish some best practices. 
>     Google style guide has these guidelines: 
> https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Lambda_expressions
>  
>     
>     Avoiding default captures is one of them; limiting the length of lambdas 
> is another.
>     
>     We should document these, at least reference Google's.
>     
>     And how about lambdas that simply call another method vs. bind? :)

Aha, good call. I checked the C++11 standard, $5.1.2/14 says that capturing a 
variable of reference type by copy will create a copy of the value referenced 
instead of creating a copy of the reference. Thus the lambda will have its own 
copy of the value that the reference was referencing when it was created.

However, looks like gcc has a bug related to capturing a reference type by 
using [=] so we should probably avoid that as much as possible
http://stackoverflow.com/questions/6529177/capturing-reference-variable-by-copy-in-c0x-lambda


- Jie


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


On July 12, 2015, 4:47 a.m., Ian Downes wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/34137/
> -----------------------------------------------------------
> 
> (Updated July 12, 2015, 4:47 a.m.)
> 
> 
> Review request for mesos, Chi Zhang, Paul Brett, Timothy Chen, and Vinod Kone.
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> The MesosContainerizer can optionally provision a root filesystem for the 
> containers.
> 
> 
> Diffs
> -----
> 
>   include/mesos/slave/isolator.hpp ef2205dd7f4619e53e6cca7cac301f874d08c036 
>   src/Makefile.am e5b5d36f0ac160e5a3a9fdc50b31c060a413ce2c 
>   src/slave/containerizer/mesos/containerizer.hpp 
> 3ac2387eabded61c897a5016655aae10cd1bca91 
>   src/slave/containerizer/mesos/containerizer.cpp 
> 47d146125dfd4ea909e7ec9d94f41cfa11d035e5 
>   src/slave/containerizer/provisioner.hpp PRE-CREATION 
>   src/slave/containerizer/provisioner.cpp PRE-CREATION 
>   src/slave/flags.hpp 26c778db2303167369af8675fe0441a00a1e9151 
>   src/slave/flags.cpp 8632677ebbdbfef8ffa45204b6f63a700baff7f3 
>   src/slave/paths.hpp 00476f107ed8233123a6eab0925c9f28aac0a86f 
>   src/slave/paths.cpp 0741616b656e947cb460dd6ee6a9a4852be001c2 
>   src/slave/state.hpp bb0eee78e118210ccd7fcbd909029412ff106128 
>   src/slave/state.cpp f8a9514f52bf9f886171c2a0e674e5a89f8dbea7 
>   src/tests/containerizer_tests.cpp 0cdb2d2a3f19a4835e85c6b040759019b03f051e 
> 
> Diff: https://reviews.apache.org/r/34137/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Ian Downes
> 
>

Reply via email to