Ejemplo n.º 1
0
 void HandleDisposed(IFuture wait)
 {
     foreach (var f in _Futures)
     {
         f.Dispose();
     }
 }
Ejemplo n.º 2
0
        public void Dispose()
        {
            _WakePrevious = null;

            if (_AwaitingCLRTask != null)
            {
                _AwaitingCLRTask.TryCancelScope();
                _AwaitingCLRTask = null;
            }

            if (WakeCondition != null)
            {
                WakeCondition.Dispose();
                WakeCondition = null;
            }

            if (_Task != null)
            {
                _Task.Dispose();
                _Task = null;
            }

            if (_Future != null)
            {
                _Future.Dispose();
                _Future = null;
            }
        }
Ejemplo n.º 3
0
        /// <inheritdoc />
        public IFuture <TR> Extract()
        {
            IFuture <TR> future = Factory.NewFuture <TR>();

            _requests.Enqueue(future);
            return(future);
        }
        private void TryRegister(Connection connection)
        {
            if (!_listenerAddedConnection.CompareAndSet(null, connection))
            {
                //already registering/registered to another connection
                return;
            }
            var clientMessage = ClientAddClusterViewListenerCodec.EncodeRequest();

            void HandlePartitionsViewEvent(int version, ICollection <KeyValuePair <Guid, IList <int> > > partitions) =>
            _partitionService.HandlePartitionsViewEvent(connection, partitions, version);

            void EventHandler(ClientMessage message) =>
            ClientAddClusterViewListenerCodec.EventHandler.HandleEvent(message, HandleMembersViewEvent,
                                                                       HandlePartitionsViewEvent);

            IFuture <ClientMessage> future = _clientInvocationService.InvokeListenerOnConnection(clientMessage, EventHandler, connection);

            future.ToTask().ContinueWith(task =>
            {
                if (!task.IsFaulted)
                {
                    if (task.Result != null)
                    {
                        return;
                    }
                }
                //completes with exception, listener needs to be re-registered
                TryReRegisterToRandomConnection(connection);
            });
        }
Ejemplo n.º 5
0
        void Step()
        {
            if (_Task == null)
            {
                return;
            }

            _AwaitingCLRTask = null;
            if (WakeCondition != null)
            {
                _WakePrevious = WakeCondition;
                WakeCondition = null;
            }

            using (_Scheduler.IsActive)
                try {
                    if (!_Task.MoveNext())
                    {
                        // Completed with no result
                        CompleteWithResult(null);
                        return;
                    }

                    // Disposed during execution
                    if (_Task == null)
                    {
                        return;
                    }

                    object value = _Task.Current;
                    ScheduleNextStep(value);
                } catch (Exception ex) {
                    Abort(ExceptionDispatchInfo.Capture(ex));
                }
        }
Ejemplo n.º 6
0
 protected internal static void NotifyListener(IEventExecutor eventExecutor, IFuture <V> future, IFutureListener <V> listener)
 {
     ObjectUtil.CheckNotNull(eventExecutor, "eventExecutor");
     ObjectUtil.CheckNotNull(future, "future");
     ObjectUtil.CheckNotNull(listener, "listener");
     _NotifyListenerWithStackOverFlowProtection(eventExecutor, future, listener);
 }
Ejemplo n.º 7
0
        internal static string DebugString(IFuture _future)
        {
            DebugHash debugHash = new DebugHash();

            _future.AccumulateRobustHash(debugHash);
            return(debugHash.ToString());
        }
Ejemplo n.º 8
0
		public CacheRecord(IFuture future)
		{
			this.future = future;
			this.wait = new CountedEventWaitHandle(false, EventResetMode.ManualReset, "CacheRecord.Wait");
			this.refs = 1;
			CacheRecord.cacheRecordsExtant.crement(1);
		}
Ejemplo n.º 9
0
        public static RunToCompletion Run(this IEnumerator <object> task, out IFuture future)
        {
            var rtc = new RunToCompletion(task, TaskExecutionPolicy.RunWhileFutureLives);

            future = rtc.Future;
            return(rtc);
        }
Ejemplo n.º 10
0
        static void DispatchNewMessage (Peer from, string message) {
            _MessageBuilder.Remove(0, _MessageBuilder.Length);
            if (from != null) {
                _MessageBuilder.Append("<");
                _MessageBuilder.Append(from);
                _MessageBuilder.Append("> ");
                _MessageBuilder.Append(message);
            } else {
                _MessageBuilder.Append("*** ");
                _MessageBuilder.Append(message);
            }

            Messages.Add(new Message { From = from, Text = message, DisplayText = _MessageBuilder.ToString() });

            if (Messages.Count > MaxMessagesToStore) {
                int numToRemove = MaxMessagesToStore / 2;
                Messages.RemoveRange(0, numToRemove);
                MessageIdBase += numToRemove;
            }

            if (WaitingForMessages != null) {
                WaitingForMessages.Complete();
                WaitingForMessages = null;
            }
        }
Ejemplo n.º 11
0
        public ProcessWatcher(TaskScheduler scheduler, params string[] processNames)
        {
            Scheduler = scheduler;

            foreach (var pname in processNames) {
                var invariant = Path.GetFileNameWithoutExtension(pname).ToLowerInvariant();
                ProcessNames.Add(invariant);

                foreach (var process in Process.GetProcessesByName(invariant)) {
                    RunningProcessIds.Add(process.Id);
                    NewProcesses.Enqueue(process);
                }
            }

            try {
                var query = new WqlEventQuery(@"SELECT * FROM Win32_ProcessStartTrace");
                Watcher = new ManagementEventWatcher(query);
                Watcher.Options.BlockSize = 1;
                Watcher.EventArrived += new EventArrivedEventHandler(OnEventArrived);
                Watcher.Start();
                WatcherEnabled = true;
            } catch {
                Watcher = null;
                WatcherEnabled = false;

                TimerTask = Scheduler.Start(InitTimer(), TaskExecutionPolicy.RunAsBackgroundTask);
            }
        }
Ejemplo n.º 12
0
        public object WaitFor(IFuture future, double?timeout = null)
        {
            if (_IsDisposed)
            {
                throw new ObjectDisposedException("TaskScheduler");
            }

            DateTime started = default(DateTime);

            if (timeout.HasValue)
            {
                started = DateTime.UtcNow;
            }

            using (IsActive)
                while (true)
                {
                    if (_JobQueue.WaitForFuture(future))
                    {
                        return(future.Result);
                    }

                    if (timeout.HasValue)
                    {
                        var elapsed = DateTime.UtcNow - started;

                        if (elapsed.TotalSeconds >= timeout)
                        {
                            throw new TimeoutException();
                        }
                    }
                }
        }
Ejemplo n.º 13
0
        // At most one of LoadSync/LoadAsync may be called for any given
        // LoadingValueReference.

        T LoadSync(string key, LoadingValueReference <T> loading_value_reference,
                   CacheLoader <T> loader)
        {
            IFuture <T> loading_future = loading_value_reference.LoadFuture(key, loader);

            return(GetUninterruptibly(key, loading_value_reference, loading_future));
        }
Ejemplo n.º 14
0
 internal void ClearPendingOperation(IFuture f)
 {
     if (Interlocked.CompareExchange(ref _PendingOperation, null, f) != f)
     {
         throw new InvalidOperationException();
     }
 }
Ejemplo n.º 15
0
        internal void QueueSleep(long completeWhen, IFuture future)
        {
            if (_IsDisposed)
            {
                return;
            }

            long now = TimeProvider.Ticks;

            if (now > completeWhen)
            {
                using (IsActive)
                    future.Complete();

                return;
            }

            SleepItem sleep = new SleepItem {
                Until = completeWhen, Future = future
            };

            lock (_SleepWorker.WorkItems)
                _SleepWorker.WorkItems.Enqueue(sleep);
            _SleepWorker.Wake();
        }
Ejemplo n.º 16
0
            void _OnDecodeComplete(IFuture f)
            {
                if (Parent.IsDisposed)
                {
                    Result.Dispose();
                    return;
                }

                var e = f.Error;

                if (e != null)
                {
                    Buffer.Dispose();
                    Result.Fail(e);
                }
                else
                {
                    int numChars = (int)f.Result;

                    if (numChars > 0)
                    {
                        ProcessDecodedChars();
                    }
                    else
                    {
                        string resultString = Buffer.DisposeAndGetContents();
                        if (resultString.Length == 0)
                        {
                            resultString = null;
                        }

                        Result.Complete(resultString);
                    }
                }
            }
Ejemplo n.º 17
0
 internal void SetPendingOperation(IFuture f)
 {
     if (Interlocked.CompareExchange(ref _PendingOperation, f, null) != null)
     {
         throw new OperationPendingException();
     }
 }
Ejemplo n.º 18
0
        static void DispatchNewMessage(Peer from, string message)
        {
            _MessageBuilder.Remove(0, _MessageBuilder.Length);
            if (from != null)
            {
                _MessageBuilder.Append("<");
                _MessageBuilder.Append(from);
                _MessageBuilder.Append("> ");
                _MessageBuilder.Append(message);
            }
            else
            {
                _MessageBuilder.Append("*** ");
                _MessageBuilder.Append(message);
            }

            Messages.Add(new Message {
                From = from, Text = message, DisplayText = _MessageBuilder.ToString()
            });

            if (Messages.Count > MaxMessagesToStore)
            {
                int numToRemove = MaxMessagesToStore / 2;
                Messages.RemoveRange(0, numToRemove);
                MessageIdBase += numToRemove;
            }

            if (WaitingForMessages != null)
            {
                WaitingForMessages.Complete();
                WaitingForMessages = null;
            }
        }
Ejemplo n.º 19
0
 void ISchedulable.Schedule(TaskScheduler scheduler, IFuture future)
 {
     _Future = future;
     _Scheduler = scheduler;
     _Future.RegisterOnDispose(this.OnDisposed);
     QueueStep();
 }
Ejemplo n.º 20
0
		public void Flush()
		{
			this.cachedCoordSys = null;
			this.cachedRendererCredit = null;
			this.cachedUserBounds = null;
			this.cachedImageRequest = null;
		}
Ejemplo n.º 21
0
        /// <summary>
        /// Waits uninterruptibly for <paramref name="new_value"/> to be loaded.
        /// </summary>
        /// <param name="key">The key associated with the laoding value.</param>
        /// <param name="loading_value_reference"></param>
        /// <param name="new_value"></param>
        /// <returns></returns>
        T GetUninterruptibly(string key,
                             LoadingValueReference <T> loading_value_reference, IFuture <T> new_value)
        {
            T value = default(T);

            try {
                value = Uninterruptibles.GetUninterruptibly(new_value);

                // Cache loader should never returns null for reference types.
                if (IsNull(value))
                {
                    throw new InvalidCacheLoadException(
                              "CacheLoader returned a null for key " + key + ".");
                }
                // TODO(neylor.silva): Record load success stats.
                StoreLoadedValue(key, loading_value_reference, value);
                return(value);
            } finally {
                if (IsNull(value))
                {
                    // TODO(neylor.silva): Record load exception stats.
                    RemoveLoadingValue(key, loading_value_reference);
                }
            }
        }
Ejemplo n.º 22
0
 public void Bind <T> (IFuture <T> future)
 {
     Reset();
     future.OnComplete(v => { successes += 1; },
                       e => { failures += 1; });
     future.OnComplete(r => { completes += 1; });
 }
        private static void TryCount(
            RegressionEnvironment env,
            int numThreads,
            int numMessages,
            string epl,
            GeneratorEnumeratorCallback generatorEnumeratorCallback)
        {
            var threadPool = Executors.NewFixedThreadPool(
                numThreads,
                new SupportThreadFactory(typeof(MultithreadStmtStatelessEnummethod)).ThreadFactory);

            env.CompileDeploy(epl);
            var listener = new SupportMTUpdateListener();

            env.Statement("s0").AddListener(listener);

            var future = new IFuture <bool> [numThreads];

            for (var i = 0; i < numThreads; i++)
            {
                future[i] = threadPool.Submit(
                    new SendEventCallable(
                        i,
                        env.Runtime,
                        new GeneratorEnumerator(numMessages, generatorEnumeratorCallback)));
            }

            threadPool.Shutdown();
            SupportCompileDeployUtil.ExecutorAwait(threadPool, 10, TimeUnit.SECONDS);
            SupportCompileDeployUtil.AssertFutures(future);

            Assert.AreEqual(numMessages * numThreads, listener.GetNewDataListFlattened().Length);
        }
Ejemplo n.º 24
0
        protected void DiffLoaded(HeapDiff diff, string filename)
        {
            Modules        = diff.Modules;
            FunctionNames  = diff.FunctionNames;
            Deltas         = diff.Deltas;
            FilteredDeltas = null;
            StackGraph     = null;

            TracebackFilter.AutoCompleteItems = FunctionNames;

            Text     = "Diff Viewer - " + filename;
            Filename = filename;

            RefreshModules();

            if (PendingRefresh != null)
            {
                PendingRefresh.Dispose();
            }
            PendingRefresh = Start(RefreshDeltas());

            MainMenuStrip.Enabled = true;
            LoadingPanel.Visible  = false;
            MainSplit.Visible     = true;
            Timeline.Enabled      = true;
            UseWaitCursor         = false;
        }
Ejemplo n.º 25
0
        private static void TryThreadSafetyHistoricalJoin(
            RegressionEnvironment env,
            int numThreads,
            int numRepeats)
        {
            var listener = new MyListener();
            env.Statement("select").AddListener(listener);

            var events = new IList<object>[numThreads];
            for (var threadNum = 0; threadNum < numThreads; threadNum++) {
                events[threadNum] = new List<object>();
                for (var eventNum = 0; eventNum < numRepeats; eventNum++) {
                    // range: 1 to 1000
                    var partition = eventNum + 1;
                    events[threadNum].Add(new SupportBean(new int?(partition).ToString(), 0));
                }
            }

            var threadPool = Executors.NewFixedThreadPool(
                numThreads,
                new SupportThreadFactory(typeof(MultithreadContextDBAccess)).ThreadFactory);
            var futures = new IFuture<bool>[numThreads];
            for (var i = 0; i < numThreads; i++) {
                var callable = new SendEventCallable(i, env.Runtime, events[i].GetEnumerator());
                futures[i] = threadPool.Submit(callable);
            }

            SupportCompileDeployUtil.AssertFutures(futures);
            threadPool.Shutdown();
            SupportCompileDeployUtil.ExecutorAwait(threadPool, 10, TimeUnit.SECONDS);

            Assert.AreEqual(numRepeats * numThreads, listener.Count);
        }
Ejemplo n.º 26
0
        public IFuture GetImageBounds(FutureFeatures features)
        {
            IFuture future = GetAccessFuture(AccessMethod.FetchBounds, FutureFeatures.Cached, new IFuture[0]);

            future = new MemCacheFuture(cachePackage.boundsCache, future);
            return(AddAsynchrony(future, features));
        }
Ejemplo n.º 27
0
        internal Size GetOutputSizeSynchronously(IFuture synchronousUserBoundsFuture)
        {
            RenderRegion renderRegionSynchronously =
                latentRegionHolder.GetRenderRegionSynchronously(synchronousUserBoundsFuture);

            return(OutputSizeFromRenderRegion(renderRegionSynchronously));
        }
        private void FutureComplete(IFuture f)
        {
            _queueFutures.Remove(f);

            if (_queueFutures.Count > 0)
            {
                if (_current == f)
                {
                    _current = _queueFutures[0];
                }
            }
            else
            {
                _current = null;
            }

            if (onFutureComplete != null)
            {
                onFutureComplete(f);
            }

            if (_current != null)
            {
                _current.Run();
            }
        }
Ejemplo n.º 29
0
        private static void TryStatementCreateSendAndStop(
            RegressionEnvironment env,
            int numThreads,
            StmtMgmtCallablePair[] statements,
            int numRepeats)
        {
            var threadPool = Executors.NewFixedThreadPool(
                numThreads,
                new SupportThreadFactory(typeof(MultithreadStmtMgmt)).ThreadFactory);
            var future = new IFuture<object>[numThreads];
            for (var i = 0; i < numThreads; i++) {
                var callable = new StmtMgmtCallable(env.Runtime, statements, numRepeats);
                future[i] = threadPool.Submit(callable);
            }

            threadPool.Shutdown();
            SupportCompileDeployUtil.ExecutorAwait(threadPool, 10, TimeUnit.SECONDS);

            var statementDigest = new StringBuilder();
            for (var i = 0; i < statements.Length; i++) {
                statementDigest.Append(statements[i].Epl);
            }

            SupportCompileDeployUtil.AssertFutures(future);
        }
Ejemplo n.º 30
0
        public void TestCursor()
        {
            var cache0 = Cache().WithAsync();

            cache0.WithAsync().Put(1, new QueryPerson("Ivanov", 30));

            IFuture <object> res = cache0.GetFuture <object>();

            res.Get();

            Cache().Put(1, new QueryPerson("Ivanov", 30));
            Cache().Put(1, new QueryPerson("Petrov", 40));
            Cache().Put(1, new QueryPerson("Sidorov", 50));

            SqlQuery qry = new SqlQuery(typeof(QueryPerson), "age >= 20");

            // 1. Test GetAll().
            using (IQueryCursor <ICacheEntry <int, QueryPerson> > cursor = Cache().Query(qry))
            {
                cursor.GetAll();

                Assert.Throws <InvalidOperationException>(() => { cursor.GetAll(); });
                Assert.Throws <InvalidOperationException>(() => { cursor.GetEnumerator(); });
            }

            // 2. Test GetEnumerator.
            using (IQueryCursor <ICacheEntry <int, QueryPerson> > cursor = Cache().Query(qry))
            {
                cursor.GetEnumerator();

                Assert.Throws <InvalidOperationException>(() => { cursor.GetAll(); });
                Assert.Throws <InvalidOperationException>(() => { cursor.GetEnumerator(); });
            }
        }
Ejemplo n.º 31
0
Archivo: IO.cs Proyecto: jli94/Fracture
            private void _OnDecodeComplete(IFuture f)
            {
                if (Parent.IsDisposed)
                {
                    Result.Dispose();
                    return;
                }

                var e = f.Error;

                if (e != null)
                {
                    Result.Fail(e);
                }
                else
                {
                    int numChars = (int)f.Result;

                    if (numChars > 0)
                    {
                        ProcessDecodedChars();
                    }
                    else
                    {
                        Result.Complete(Position - InitialPosition);
                    }
                }
            }
Ejemplo n.º 32
0
 public static void Future([ValidatedNotNull] IFuture aFuture)
 {
     if (aFuture == null)
     {
         throw new ActorException("future must exist");
     }
 }
Ejemplo n.º 33
0
        public bool WaitForFuture(IFuture future)
        {
            Action item;

            while (!future.Completed)
            {
                if (_Disposed)
                {
                    throw new ObjectDisposedException("ThreadSafeJobQueue");
                }
                if (future.Disposed)
                {
                    throw new FutureDisposedException(future);
                }

                if (_Queue.TryDequeue(out item))
                {
                    item();
                }
                else
                {
                    Thread.Sleep(0);
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 34
0
 private void _RequestOnComplete(IFuture future)
 {
     if (future.Failed)
     {
         OnRequestError(future.Error);
     }
 }
Ejemplo n.º 35
0
        public IEnumerator <object> Talk()
        {
            int state = 30;

            while (true)
            {
                NumSteps += 1;
                if (state <= 0)
                {
                    yield break;
                }

                ChattyEntity sibling = GetRandomSibling();
                sibling.Tell(state - 1);
                yield return(new WaitForNextStep());

                IFuture response = _Messages.Dequeue();
                using (response)
                    yield return(response);

                if (response.Disposed)
                {
                    yield break;
                }
                state = (int)response.Result;
            }
        }
		private IFuture GetAccessFuture(AccessMethod accessMethod, FutureFeatures openDocFeatures, params IFuture[] methodParams)
		{
			IFuture[] array = new IFuture[2 + methodParams.Length];
			array[0] = this.GetOpenDocumentFuture(openDocFeatures);
			array[1] = new ConstantFuture(new IntParameter((int)accessMethod));
			Array.Copy(methodParams, 0, array, 2, methodParams.Length);
			return new ApplyFuture(new ApplyVerbPresent(), array);
		}
Ejemplo n.º 37
0
Archivo: Menu.cs Proyecto: kg/rlms2013
        public Menu(Game game, string description, IFuture future, params IMenuItem[] items)
        {
            Game = game;
            Description = description;
            Font = game.UIText;

            Items.AddRange(items);
        }
Ejemplo n.º 38
0
		public void RequestRenderRegion(IFuture asynchronousImageBoundsFuture)
		{
			if (this.renderRegion == null)
			{
				AsyncRef asyncRef = (AsyncRef)asynchronousImageBoundsFuture.Realize("LatentRegionHolder.RequestRenderRegion");
				asyncRef.AddCallback(new AsyncRecord.CompleteCallback(this.ImageBoundsAvailable));
				new PersistentInterest(asyncRef);
			}
		}
Ejemplo n.º 39
0
		public RenderRegion GetRenderRegionSynchronously(IFuture synchronousImageBoundsFuture)
		{
			Present present = synchronousImageBoundsFuture.Realize("LatentRegionHolder.GetRenderRegionSynchronously");
			this.StoreRenderRegion(present);
			if (this.renderRegion == null)
			{
				throw new Exception("Render region request failed, gasp: " + present.ToString());
			}
			return this.renderRegion;
		}
Ejemplo n.º 40
0
 IEnumerator<object> BeginSearch()
 {
     ActiveSearchQuery = PendingSearchQuery;
     PendingSearchQuery = null;
     ActiveSearch = Program.Scheduler.Start(
         PerformSearch(ActiveSearchQuery),
         TaskExecutionPolicy.RunAsBackgroundTask
     );
     yield break;
 }
Ejemplo n.º 41
0
        void ISchedulable.Schedule(TaskScheduler scheduler, IFuture future)
        {
            if (future == null)
                throw new ArgumentNullException("future");

            _Future = future;
            _Scheduler = scheduler;
            _Future.RegisterOnDispose(this.OnDisposed);
            QueueStep();
        }
Ejemplo n.º 42
0
		public IFuture GetUserBounds(LatentRegionHolder latentRegionHolder, FutureFeatures features)
		{
			if (this.cachedUserBounds == null || this.lastUserBoundsRequest_latentRegionHolder != latentRegionHolder || this.lastUserBoundsRequest_features != features)
			{
				this.lastUserBoundsRequest_latentRegionHolder = latentRegionHolder;
				this.lastUserBoundsRequest_features = features;
				this.cachedUserBounds = this.backingSource.GetUserBounds(latentRegionHolder, features);
			}
			return this.cachedUserBounds;
		}
Ejemplo n.º 43
0
		public AsyncRecord(AsyncScheduler scheduler, IFuture cacheKeyToEvict, IFuture future)
		{
			this._cacheKeyToEvict = cacheKeyToEvict;
			this._future = future;
			this.scheduler = scheduler;
			this._present = null;
			this.asyncState = AsyncState.Prequeued;
			this.queuePriority = 0;
			this.qtpRef = new AsyncRef(this, "qRef");
		}
Ejemplo n.º 44
0
        public void Dispose()
        {
            if (Data != null) {
                Data.Dispose();
                Data = null;
            }

            if (_SendFuture != null) {
                _SendFuture.Dispose();
                _SendFuture = null;
            }
        }
Ejemplo n.º 45
0
		public override Present Get(IFuture future, string refCredit)
		{
			if (SizeSensitiveCache.oneEntryAtATime)
			{
				Present present = base.Lookup(future);
				if (present != null)
				{
					return present;
				}
			}
			return base.Get(future, refCredit);
		}
Ejemplo n.º 46
0
 internal TelnetClient (TelnetServer server, TcpClient client) {
     Server = server;
     client.Client.NoDelay = true;
     client.Client.Blocking = false;
     Data = new SocketDataAdapter(client.Client, true);
     Data.ThrowOnDisconnect = false;
     Data.ThrowOnFullSendBuffer = false;
     Encoding encoding = Encoding.ASCII;
     Input = new AsyncTextReader(Data, encoding);
     Output = new AsyncTextWriter(Data, encoding);
     Output.AutoFlush = true;
     _SendFuture = server._Scheduler.Start(SendMessagesTask(), TaskExecutionPolicy.RunWhileFutureLives);
 }
Ejemplo n.º 47
0
		public UserBoundsRefVerb(LatentRegionHolder latentRegionHolder, IFuture delayedStaticBoundsFuture)
		{
			RenderRegion renderRegion = latentRegionHolder.renderRegion;
			if (renderRegion == null)
			{
				this.userRegion = null;
			}
			else
			{
				this.userRegion = renderRegion.Copy(new DirtyEvent());
			}
			this.delayedStaticBoundsFuture = delayedStaticBoundsFuture;
		}
Ejemplo n.º 48
0
        void QueueStepOnComplete (IFuture f) {
            if (_WakeDiscardingResult && f.Failed) {
                Abort(f.Error);
                return;
            }

            if (WakeCondition != null) {
                _WakePrevious = WakeCondition;
                WakeCondition = null;
            }

            _Scheduler.QueueWorkItem(_Step);
        }
Ejemplo n.º 49
0
        public void Dispose()
        {
            if (Watcher != null) {
                Watcher.Stop();
                Watcher.Dispose();
                Watcher = null;
            }

            if (TimerTask != null) {
                TimerTask.Dispose();
                TimerTask = null;
            }
        }
Ejemplo n.º 50
0
        protected Endpoint(JabberGateway gateway, EndpointSettings settings, Session session)
        {
            Gateway = gateway;
            Settings = settings;
            Session = session;
            Queue = Gateway.GetQueue(settings.Name);

            Endpoint oldEndpoint = null;
            if (gateway.Endpoints.TryGetValue(settings.Name, out oldEndpoint) && (oldEndpoint != null))
                oldEndpoint.Dispose();

            gateway.Endpoints[settings.Name] = this;

            QueueTaskFuture = Program.Scheduler.Start(QueueTask(), TaskExecutionPolicy.RunAsBackgroundTask);
        }
		public OpenDocumentSensitivePrioritizedFuture(OpenDocumentSensitivePrioritizer prioritizer, IFuture future, IFuture openDocumentFuture)
		{
			this.prioritizer = prioritizer;
			this.future = future;
			this.openDocumentFuture = openDocumentFuture;
			object obj;
			Monitor.Enter(obj = OpenDocumentSensitivePrioritizedFuture.nextIdentityMutex);
			try
			{
				this._identity = OpenDocumentSensitivePrioritizedFuture.nextIdentity;
				OpenDocumentSensitivePrioritizedFuture.nextIdentity++;
			}
			finally
			{
				Monitor.Exit(obj);
			}
		}
Ejemplo n.º 52
0
        public void Dispose () {
            _WakePrevious = null;

            if (WakeCondition != null) {
                WakeCondition.Dispose();
                WakeCondition = null;
            }

            if (_Task != null) {
                _Task.Dispose();
                _Task = null;
            }

            if (_Future != null) {
                _Future.Dispose();
                _Future = null;
            }
        }
Ejemplo n.º 53
0
		public Present Get(IFuture future, string refCredit)
		{
			string text = this.makeCachePathname(future, "fresh.");
			string text2 = this.makeCachePathname(future, "stale.");
			Monitor.Enter(this);
			try
			{
				long num;
				Present present = this.Fetch(text, out num);
				if (present != null)
				{
					D.Sayf(10, "fresh hit! {0}", new object[]
					{
						"fresh."
					});
					Present result = present;
					return result;
				}
				present = this.Fetch(text2, out num);
				if (present != null)
				{
					File.Move(text2, text);
					this.IncrementFreshCount(num);
					D.Sayf(10, "stale hit! {0} {1}", new object[]
					{
						"stale.",
						num
					});
					Present result = present;
					return result;
				}
			}
			finally
			{
				Monitor.Exit(this);
			}
			Present result2 = future.Realize(refCredit);
			this.ScheduleDeferredWrite(result2, text, future.ToString());
			D.Sayf(10, "miss", new object[0]);
			return result2;
		}
Ejemplo n.º 54
0
		public Present Lookup(IFuture future)
		{
			Monitor.Enter(this);
			CacheRecord cacheRecord;
			try
			{
				if (!this.cache.ContainsKey(future))
				{
					return null;
				}
				cacheRecord = this.cache[future];
				this.Touch(cacheRecord, false);
				cacheRecord.AddReference();
			}
			finally
			{
				Monitor.Exit(this);
			}
			Present result = cacheRecord.WaitResult("lookup", this.hashName);
			cacheRecord.DropReference();
			return result;
		}
Ejemplo n.º 55
0
		public bool Contains(IFuture future)
		{
			Monitor.Enter(this);
			bool result;
			try
			{
				if (this.cache.ContainsKey(future))
				{
					this.Touch(this.cache[future], false);
					result = true;
				}
				else
				{
					result = false;
				}
			}
			finally
			{
				Monitor.Exit(this);
			}
			return result;
		}
Ejemplo n.º 56
0
        public void Dispose()
        {
            _WakePrevious = null;

            if (_AwaitingCLRTask != null) {
                _AwaitingCLRTask.TryCancelScope();
                _AwaitingCLRTask = null;
            }

            if (WakeCondition != null) {
                WakeCondition.Dispose();
                WakeCondition = null;
            }

            if (_Task != null) {
                _Task.Dispose();
                _Task = null;
            }

            if (_Future != null) {
                _Future.Dispose();
                _Future = null;
            }
        }
Ejemplo n.º 57
0
        private void TracebackFilter_FilterChanged(object sender, EventArgs e)
        {
            var filter = MainWindow.FilterToRegex(TracebackFilter.Filter);
            GraphHistogram.FunctionFilter = DeltaHistogram.FunctionFilter = DeltaList.FunctionFilter = FunctionFilter = filter;

            if (PendingRefresh != null)
                PendingRefresh.Dispose();

            PendingRefresh = Start(RefreshDeltas());
        }
Ejemplo n.º 58
0
        private void Timeline_RangeChanged(object sender, EventArgs e)
        {
            var pair = Timeline.Selection;

            if (pair.CompareTo(PendingLoadPair) != 0) {
                if (PendingLoad != null) {
                    PendingLoad.Dispose();
                    PendingLoad = null;
                    PendingLoadPair = Pair.New(-1, -1);
                }
            } else {
                return;
            }

            if (pair.CompareTo(CurrentPair) != 0)
                PendingLoad = Start(LoadRange(pair));
        }
Ejemplo n.º 59
0
 private void ModuleList_FilterChanged(object sender, EventArgs e)
 {
     if (PendingRefresh != null)
         PendingRefresh.Dispose();
     PendingRefresh = Start(RefreshDeltas());
 }
Ejemplo n.º 60
0
        protected void SetGraphKeyType(GraphKeyType keyType)
        {
            if (keyType != StackGraphKeyType) {
                StackGraphKeyType = keyType;

                GraphHistogram.Items = GraphTreemap.Items = new StackGraphNode[0];
                GraphHistogram.Invalidate();
                GraphTreemap.Invalidate();

                if (PendingRefresh != null)
                    PendingRefresh.Dispose();
                PendingRefresh = Start(RefreshGraph());
            }
        }