예제 #1
0
        public void Scenario5ImListAtomic()
        {
            var lst   = new AtomicReference <ImList <D> >(new ImList <D>());
            var datas = GetDatas();

            Run(
                () => {
                foreach (var d in datas.datas1)
                {
                    lst.Mutate1(d, (item, lst) => lst.Add(item));
                    eatTime();
                }
            },
                () => {
                foreach (var d in datas.datas2)
                {
                    lst.Mutate1(d, (item, lst) => lst.Add(item));
                    eatTime();
                }
            }
                );

            for (int idx = 1; idx <= cntRead; idx++)
            {
                var a = lst.Value.ToArray();
                if (a.Length != 2 * cntAdd)
                {
                    throw new Exception($"{a.Length} != 2*{cntAdd}");
                }
            }
        }