Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
Lazy evaluation refers to a variety of concepts that seek to avoid evaluation of an expression unless its value is needed, and to share the results of evaluation of an expression among all uses of its, so that no expression need be evaluated more than once.
1
vote
Own implementation of Lazy<T> object
I've done the same analysis for .NET Core version of Lazy and stripped out the following that do not suit my needs anyway in this case (the new Lazy(Func<T>) constructor)
Exception caching
all the other … internal class LazyHelper
{
internal LazyHelper()
{
}
}
public class Lazy<T>
{
private volatile LazyHelper _state;
private Func<T> _factory;
private T _value;
public Lazy …
0
votes
Own implementation of Lazy<T> object
Not stopping my curiousity I took the .NET source of Lazy and stripped out the following that do not suit my needs anyway in this case:
Exception caching
all the other modes then ExecutionAndPublication … any other things like Debugger visualization, ToString() etc
Inlined some functions that stopped having any logic because of stripping the other things
This is the result until now of the stripped Lazy …
3
votes
Own implementation of Lazy<T> object
(I think) I literally copied the locking structure of Lazy, thread-safe Singleton
Included adding the volatile keyword for the _Loaded check
Moved the generic definition to the class type. … as the Lazy<T>, see:
/// https://codereview.stackexchange.com/questions/207708/own-implementation-of-lazyt-object
/// </summary>
public class MyLazy<T>
{
private T _Value;
private …
27
votes
11
answers
7k
views
Own implementation of Lazy<T> object
The problem with the original Lazy in C# is that you have to put the initialization in the constructor if you want to refer to this.
For me that is 95% of the cases. … Meaning that I have to put half of my logic concerning the lazy property in the constructor, and having more boilerplate code. …