コード例 #1
0
        void EnsureInitializedCore()
        {
            lock (syncLock)
            {
                if (!Volatile.Read(ref initialized))
                {
                    var f = Interlocked.Exchange(ref taskFactory, null);
                    if (f != null)
                    {
                        var task    = f();
                        var awaiter = task.GetAwaiter();
                        if (awaiter.IsCompleted)
                        {
                            SetCompletionSource(awaiter);
                        }
                        else
                        {
                            this.awaiter = awaiter;
                            awaiter.SourceOnCompleted(continuation, this);
                        }

                        Volatile.Write(ref initialized, true);
                    }
                }
            }
        }
コード例 #2
0
        internal AsyncLazy(UniTask task)
        {
            this.taskFactory      = null;
            this.completionSource = new UniTaskCompletionSource();
            this.syncLock         = null;
            this.initialized      = true;

            var awaiter = task.GetAwaiter();

            if (awaiter.IsCompleted)
            {
                SetCompletionSource(awaiter);
            }
            else
            {
                this.awaiter = awaiter;
                awaiter.SourceOnCompleted(continuation, this);
            }
        }
コード例 #3
0
ファイル: UniTask.Factory.cs プロジェクト: WARP-D/Hikari
 public void OnCompleted(Action <object> continuation, object state, short token)
 {
     awaiter.SourceOnCompleted(continuation, state);
 }