예제 #1
0
        public async Task DoC(string name)
        {
            Console.WriteLine($"{name} created");

            // calculate accessScope
            long accessScope = 3;

            using (IAccessContext <long> q
                       = Context.CreateChild(accessScope))
            {
                char contextName = NewContextName();

                await q.UntilAvailable();

                await Task.Run(() =>
                {
                    for (int i = 0; i < 5; i++)
                    {
                        work(q, name, contextName, "DoC");
                    }

                    q.RequiredScope = 1;

                    // perform something here
                    for (int i = 0; i < 6; i++)
                    {
                        work(q, name, contextName, "DoC");
                    }
                });
            }
        }
예제 #2
0
            private async Task <long> readNextIndex(
                IAccessContext <enumeratorScope> subContext)
            {
                await subContext.UntilAvailable(
                    new enumeratorScope(nextIndex : RWScope.Read));

                return(nextIndex);
            }
예제 #3
0
            private async Task setCurrentNode(
                node value, IAccessContext <enumeratorScope> subContext)
            {
                await subContext.UntilAvailable(
                    new enumeratorScope(RWScope.ReadWrite));

                currentNode = value;
            }
예제 #4
0
            private async Task <node> readCurrentNode(
                IAccessContext <enumeratorScope> subContext)
            {
                await subContext.UntilAvailable(
                    new enumeratorScope(RWScope.Read));

                return(currentNode);
            }
예제 #5
0
        /// <remarks>
        /// No child context of <paramref name="context"/>
        /// may be created und employed before
        /// the invocation of this method because
        /// this method itself does not create an own child context.
        /// </remarks>
        private async Task <node> getFirstNode(IAccessContext <CSScope> context)
        {
            await context.UntilAvailable(new CSScope(
                                             valueScope : InfiniteIntervalScope.Create(
                                                 RWScope.Read, 0, 1)));

            return(state.FirstNode);
        }
예제 #6
0
 private async Task incrementNextIndex(
     IAccessContext <enumeratorScope> subContext)
 {
     /* These two statemets (InChild and UntilAvailable)
      * could possibly be combined to a single
      * (extension) method for AccessContext. */
     await subContext.InChild(new enumeratorScope(
                                  nextIndex : RWScope.ReadWrite), async c =>
     {
         await subContext.UntilAvailable();
         nextIndex++;
     });
 }
예제 #7
0
        /* Private methods may get the surrounding context to spare
         * the creation of a new Contextual instance. */

        /// <remarks>
        /// No child context of <paramref name="context"/>
        /// may be created und employed before
        /// the invocation of this method because
        /// this method itself does not create an own child context.
        /// </remarks>
        private async Task <long> getCount(IAccessContext <CSScope> context)
        {
            await context.UntilAvailable(new CSScope(RWScope.Read));

            return(state.Count);
        }