X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FLazy.h;h=bb6411f8e44809470f03d1585505f36c175f9d8e;hb=4a9aef96b778f9fa7b31f94196e46b5733335326;hp=2b18ea7b84b36fdb9588c96a87d0f949a8bf6009;hpb=12c8603da89f7ea8f2fbd0a414125aa8117ac97b;p=folly.git diff --git a/folly/Lazy.h b/folly/Lazy.h index 2b18ea7b..bb6411f8 100644 --- a/folly/Lazy.h +++ b/folly/Lazy.h @@ -1,5 +1,5 @@ /* - * Copyright 2013 Facebook, Inc. + * Copyright 2014 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ #include #include -#include "folly/Optional.h" +#include namespace folly { @@ -35,8 +35,8 @@ namespace folly { * The value is created using folly::lazy, usually with a lambda, and * its value is requested using operator(). * - * Note that the value is not safe for current accesses by multiple - * threads, even if you declare it const. + * Note that the value is not safe for concurrent accesses by multiple + * threads, even if you declare it const. See note below. * * * Example Usage: @@ -70,6 +70,16 @@ namespace folly { * value unnecessarily. Sharing with mutable lazies would also * leave them with non-value semantics despite looking * value-like. + * + * - Not thread safe for const accesses. Many use cases for lazy + * values are local variables on the stack, where multiple + * threads shouldn't even be able to reach the value. It still + * is useful to indicate/check that the value doesn't change with + * const, particularly when it is captured by a large family of + * lambdas. Adding internal synchronization seems like it would + * pessimize the most common use case in favor of less likely use + * cases. + * */ //////////////////////////////////////////////////////////////////////