Ejemplo n.º 1
0
        public bool DoOneInteractive(Frame topFrame)
        {
            bool continueInteraction;
            Stmt s = ReadStatement(out continueInteraction);

            if (continueInteraction == false)
            {
                return(false);
            }

            //  's' is null when we parse a line composed only of a NEWLINE (interactive_input grammar);
            //  we don't generate anything when 's' is null
            if (s != null)
            {
                FrameCode code = OutputGenerator.GenerateSnippet(context, s, true);

                if (ExecWrapper != null)
                {
                    CallTarget0 t = delegate() {
                        try { code.Run(topFrame); } catch (Exception e) { DumpException(e); }
                        return(null);
                    };
                    object callable = new Function0(topFrame.__module__, "wrapper", t, new string[0], new object[0]);
                    Ops.Call(ExecWrapper, callable);
                }
                else
                {
                    code.Run(topFrame);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Start the function using ThreadPool.
        /// </summary>
        /// <param name='function'>
        /// Function.
        /// </param>
        /// <typeparam name='T'>
        /// Result type.
        /// </typeparam>
        public static Future <T> Start <T>(Function0 <T> function)
        {
            var f = new FutureImpl <T>();

            ThreadPool.QueueUserWorkItem(WorkerMethod <T>,
                                         Tuples.Tuple <FutureImpl <T>, Function0 <T> >(f, function));

            return(f);
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void getIfAbsentPut_Supplier()
        internal virtual void getIfAbsentPut_Supplier()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.block.function.Function0<org.neo4j.values.storable.Value> supplier = mock(org.eclipse.collections.api.block.function.Function0.class);
            Function0 <Value> supplier = mock(typeof(Function0));

            doReturn(intValue(10), intValue(11), intValue(12)).when(supplier).value();

            assertEquals(intValue(10), _map.getIfAbsentPut(0, supplier));
            assertEquals(intValue(11), _map.getIfAbsentPut(1, supplier));
            assertEquals(intValue(12), _map.getIfAbsentPut(2, supplier));
            verify(supplier, times(3)).value();

            assertEquals(intValue(10), _map.getIfAbsentPut(0, supplier));
            assertEquals(intValue(11), _map.getIfAbsentPut(1, supplier));
            assertEquals(intValue(12), _map.getIfAbsentPut(2, supplier));
            verifyNoMoreInteractions(supplier);
        }