Exemplo n.º 1
0
        public void wait()
        {
            if (contextGroup.firstContext != null)
            {
                NativeContext context = dispatcher.getCurrentContext();
                context.next = null;

                Debug.Assert(!context.inExecutionQueue);
                context.inExecutionQueue = true;

                if (contextGroup.firstWaiter != null)
                {
                    Debug.Assert(contextGroup.lastWaiter.next == null);
                    contextGroup.lastWaiter.next = context;
                }
                else
                {
                    contextGroup.firstWaiter = context;
                }

                contextGroup.lastWaiter = context;
                dispatcher.dispatch();
                Debug.Assert(context == dispatcher.getCurrentContext());
            }
        }
Exemplo n.º 2
0
//C++ TO C# CONVERTER TODO TASK: 'rvalue references' have no equivalent in C#:
        public void spawn(Action && procedure)
        {
            Debug.Assert(dispatcher != null);
            NativeContext context = dispatcher.getReusableContext();

            if (contextGroup.firstContext != null)
            {
                context.groupPrev = contextGroup.lastContext;
                Debug.Assert(contextGroup.lastContext.groupNext == null);
                contextGroup.lastContext.groupNext = context;
            }
            else
            {
                context.groupPrev         = null;
                contextGroup.firstContext = context;
                contextGroup.firstWaiter  = null;
            }

            context.interrupted      = false;
            context.group            = contextGroup;
            context.groupNext        = null;
            context.procedure        = std::move(procedure);
            contextGroup.lastContext = context;
            dispatcher.pushContext(context);
        }