Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="monitoredObject"></param>
        public PriorityMonitor(T monitoredObject)
        {
            MonitoredObject = monitoredObject;
            _priorityIndex  = new NonUniqueIndex <int, LockRequest>(
                "priorityIndex",
                item => GetKeyResponse.Create(true, item.Priority),
                SortOrder.Ascending);

            _lockRequests = new IndexableCollection <LockRequest>(_priorityIndex);
        }
Пример #2
0
        public void AddIndexer <P>(Indexer <T, P> indexer)
        {
            var index = new NonUniqueIndex <T, P>(this.holder, indexer);

            index.Build();

            this.rwLock.EnterWriteLock();
            try
            {
                this.indexStorage.AddIndexer(indexer, index);
            }
            finally
            {
                this.rwLock.ExitWriteLock();
            }
        }
Пример #3
0
    public CommandLine(string commandLine)
    {
        ArgumentNullException.ThrowIfNull(commandLine);

        _arguments = new IndexableCollection <CommandLineArgument>(ListIndex);
        var dictionary = new Dictionary <string, ICollection <CommandLineArgument> >(StringComparer.InvariantCultureIgnoreCase);

        NameIndex = new NonUniqueIndex <string, CommandLineArgument>(
            "nameIndex",
            argument => GetKeyResponse.Create(argument.Name != null, argument.Name),
            dictionary,
            () => new List <CommandLineArgument>());
        _arguments.Indexes.Add(NameIndex);
        var stringReader = new StringReader(commandLine);
        var arguments    = Parse(stringReader);

        _arguments.Add(arguments);
    }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="maximumConcurrencyLevel"></param>
        /// <param name="timerPeriod"></param>
        public MemoryCache(int maximumConcurrencyLevel, TimeSpan timerPeriod)
        {
            this.keyIndex = new UniqueIndex <string, CacheEntry>(
                "key",
                entry => GetKeyResponse.Create(true, entry.CacheItem.Key),
                SortOrder.None);

            this.absoluteExpirationIndex = new NonUniqueIndex <DateTime, CacheEntry>(
                "absoluteExpiration",
                entry => GetKeyResponse.Create(true, entry.AbsoluteExpiration),
                SortOrder.Ascending);

            this.entries = new IndexableCollection <CacheEntry>(this.keyIndex);
            this.entries.Indexes.Add(this.absoluteExpirationIndex);

            this.scheduler = new LimitedConcurrencyLevelTaskScheduler("MemoryCache", maximumConcurrencyLevel, new ConcurrentQueue <Action>());

            this.timer = new Timer(this.TimerCallback, null, timerPeriod, timerPeriod);
        }
Пример #5
0
 /// <summary>
 ///
 /// </summary>
 public ObjectPool()
 {
     _objects = new NonUniqueIndex <int, T>(null, @object => new GetKeyResponse <int>(true, @object.GetHashCode()), SortOrder.None);
 }