コード例 #1
0
        /// <summary>
        /// Bitmap cache get -> thread hand off -> multiplex -> bitmap cache.
        /// </summary>
        /// <param name="inputProducer">
        /// Producer providing the input to the bitmap cache.
        /// </param>
        /// <returns>
        /// Bitmap cache get to bitmap cache sequence.
        /// </returns>
        private IProducer <CloseableReference <CloseableImage> > NewBitmapCacheGetToBitmapCacheSequence(
            IProducer <CloseableReference <CloseableImage> > inputProducer)
        {
            BitmapMemoryCacheProducer bitmapMemoryCacheProducer =
                _producerFactory.NewBitmapMemoryCacheProducer(inputProducer);

            BitmapMemoryCacheKeyMultiplexProducer bitmapKeyMultiplexProducer =
                _producerFactory.NewBitmapMemoryCacheKeyMultiplexProducer(bitmapMemoryCacheProducer);

            ThreadHandoffProducer <CloseableReference <CloseableImage> > threadHandoffProducer =
                _producerFactory.NewBackgroundThreadHandoffProducer(
                    bitmapKeyMultiplexProducer,
                    _threadHandoffProducerQueue);

            return(_producerFactory.NewBitmapMemoryCacheGetProducer(threadHandoffProducer));
        }
コード例 #2
0
        public void Initialize()
        {
            // Initializes mock data
            _inputProducer = new ProducerImpl <object>((consumer, producerContext) =>
            {
                _internalConsumer        = consumer;
                _internalProducerContext = (SettableProducerContext)producerContext;
                _completion.Set();
            });

            _consumer = new BaseConsumerImpl <object>(
                (_, __) => { },
                (_) => { },
                () =>
            {
                ++_consumerOnCancellationCount;
                _completion.Set();
            },
                (_) => { });

            _producerListener = new ProducerListenerImpl(
                (requestId, producerName) =>
            {
                ++_onProducerStartCount;
                _internalRequestId    = requestId;
                _internalProducerName = producerName;
            },
                (_, __, ___) =>
            {
                ++_onProducerEventCount;
            },
                (requestId, producerName, extraMap) =>
            {
                ++_onProducerFinishWithSuccessCount;
                _internalRequestId    = requestId;
                _internalProducerName = producerName;
                _internalExtraMap     = extraMap;
            },
                (_, __, ___, ____) =>
            {
                ++_onProducerFinishWithFailureCount;
                _completion.Set();
            },
                (requestId, producerName, extraMap) =>
            {
                ++_onProducerFinishWithCancellationCount;
                _internalRequestId    = requestId;
                _internalProducerName = producerName;
                _internalExtraMap     = extraMap;
            },
                (_) =>
            {
                ++_requiresExtraMapCount;
                return(false);
            });

            _producerContext = new SettableProducerContext(
                IMAGE_REQUEST,
                REQUEST_ID,
                _producerListener,
                new object(),
                RequestLevel.FULL_FETCH,
                false,
                true,
                Priority.MEDIUM);

            _testExecutorService   = new MockSerialExecutorService();
            _threadHandoffProducer = new ThreadHandoffProducer <object>(
                _inputProducer,
                new ThreadHandoffProducerQueue(_testExecutorService));

            _completion = new ManualResetEvent(false);
        }