Exemplo n.º 1
0
        public virtual V get(K key)
        {
            V value = cache.get(key);

            if (value != default(V))
            {
                keys.remove(key);
                keys.add(key);
            }
            return(value);
        }
Exemplo n.º 2
0
        private static void addListToHead(PspGeList list)
        {
            lock (drawListQueue)
            {
                // The ConcurrentLinkedQueue type doesn't allow adding
                // objects directly at the head of the queue.

                // This function creates a new array using the given list as it's head
                // and constructs a new ConcurrentLinkedQueue based on it.
                // The actual drawListQueue is then replaced by this new one.
                int arraySize = drawListQueue.size();

                if (arraySize > 0)
                {
                    PspGeList[] array = drawListQueue.toArray(new PspGeList[arraySize]);

                    ConcurrentLinkedQueue <PspGeList> newQueue = new ConcurrentLinkedQueue <PspGeList>();
                    PspGeList[] newArray = new PspGeList[arraySize + 1];

                    newArray[0] = list;
                    for (int i = 0; i < arraySize; i++)
                    {
                        newArray[i + 1] = array[i];
                        newQueue.add(newArray[i]);
                    }

                    drawListQueue = newQueue;
                }
                else
                {                 // If the queue is empty.
                    drawListQueue.add(list);
                }
            }
        }
Exemplo n.º 3
0
        public static void startList(PspGeList list)
        {
            if (list == null)
            {
                return;
            }

            lock (drawListQueue)
            {
                if (currentList == null)
                {
                    if (State.captureGeNextFrame)
                    {
                        State.captureGeNextFrame         = false;
                        CaptureManager.captureInProgress = true;
                        NativeUtils.DumpFrames           = true;
                        NativeUtils.DumpTextures         = true;
                        logLevel  = log.Level;
                        log.Level = Level.TRACE;
                    }

                    // Save the context at the beginning of the list processing to the given address (used by sceGu).
                    if (list.hasSaveContextAddr())
                    {
                        saveContext(list.SaveContextAddr);
                    }

                    list.status = sceGe_user.PSP_GE_LIST_DRAWING;
                    NativeUtils.setLogLevel();
                    NativeUtils.CoreSadr = list.StallAddr;
                    NativeUtils.setCoreCtrlActive();
                    lock (screenScaleLock)
                    {
                        // Update the screen scale only at the start of a new list
                        NativeUtils.ScreenScale = ScreenScale;
                    }
                    currentList = list;
                    currentList.sync();
                    CoreThread.Instance.sync();
                }
                else
                {
                    drawListQueue.add(list);
                }
            }
        }
Exemplo n.º 4
0
        /* ---- many producers ---- */

        public override void Produce(T t)
        {
            _queue.add(t);
            int newSize = _size.incrementAndGet();

            if (newSize > _maxSize)
            {
                _queue.poll();
                _size.decrementAndGet();
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Called from VideoEngine </summary>
        public virtual void hleGeListSyncDone(PspGeList list)
        {
            //if (log.DebugEnabled)
            {
                string msg = "hleGeListSyncDone list " + list;

                if (list.Done)
                {
                    msg += ", done";
                }
                else
                {
                    msg += ", NOT done";
                }

                if (list.blockedThreadIds.Count > 0 && list.status != PSP_GE_LIST_END_REACHED)
                {
                    msg += ", waking thread";
                    foreach (int threadId in list.blockedThreadIds)
                    {
                        msg += " " + threadId.ToString("x");
                    }
                }

                Console.WriteLine(msg);
            }

            lock (this)
            {
                if (list.blockedThreadIds.Count > 0 && list.status != PSP_GE_LIST_END_REACHED)
                {
                    // things might go wrong if the thread already exists in the queue
                    deferredThreadWakeupQueue.addAll(list.blockedThreadIds);
                }

                if (list.Done)
                {
                    listFreeQueue.add(list);
                }
            }
        }
Exemplo n.º 6
0
        public override void start()
        {
            Console.WriteLine(string.Format("Starting {0}", Name));

            waitingForSync = false;
            syncDone       = false;

            signalCallbacks = new Dictionary <int, SceKernelCallbackInfo>();
            finishCallbacks = new Dictionary <int, SceKernelCallbackInfo>();

            listFreeQueue = new ConcurrentLinkedQueue <PspGeList>();
            allGeLists    = new PspGeList[NUMBER_GE_LISTS];
            for (int i = 0; i < NUMBER_GE_LISTS; i++)
            {
                allGeLists[i] = new PspGeList(i);
                listFreeQueue.add(allGeLists[i]);
            }

            deferredThreadWakeupQueue = new ConcurrentLinkedQueue <int>();

            eDRAMMemoryWidth = 1024;

            base.start();
        }