⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xferqueue.h

📁 freescale i.mx31 BSP CE5.0全部源码
💻 H
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//

#ifndef _XFERQUEUE_H_
#define _XFERQUEUE_H_

#include <usbfn.h>
#include <block_allocator.hxx>
#include <list.hxx>


// Access to this structure must be protected by a critical section.
template <class T>
class CTransferQueue {
public:
    CTransferQueue() : m_queue(ListStructAllocatorSingleton::instance()) {
    }

    ~CTransferQueue() {
        DEBUGCHK(IsEmpty());
    }

    BOOL IsEmpty() const {
        BOOL fRet = m_queue.empty();
        return fRet;
    }

    T* Front() const {
        DEBUGCHK(IsEmpty() == FALSE);
        return m_queue.front();
    }

    T* Back() const {
        DEBUGCHK(IsEmpty() == FALSE);
        return m_queue.back();
    }
    
    DWORD PushBack(T* pTransfer) {
        DWORD dwErr = ERROR_SUCCESS;
        
        if (!m_queue.push_back(pTransfer)) {
            dwErr = ERROR_GEN_FAILURE;
        }

        return dwErr;
    }

    VOID PopFront() {
        DEBUGCHK(IsEmpty() == FALSE);
        return m_queue.pop_front();
    }

    VOID PopBack() {
        DEBUGCHK(IsEmpty() == FALSE);
        return m_queue.pop_back();
    }

    static VOID InitializeClass(DWORD dwListSize) {
        ListStructAllocatorSingleton::init(dwListSize);
        ListStructAllocatorSingleton::addref(); // Initialize the allocator singleton
    }
    
    static VOID DeinitializeClass() {
        ListStructAllocatorSingleton::release(); // Free the allocator singleton
    }
    
    
private:
    typedef ce::fixed_block_allocator<> ListStructAllocator; 
    typedef ce::singleton<ListStructAllocator> ListStructAllocatorSingleton;
    typedef ce::list<T*, ListStructAllocator> ActualTransferQueue;
    
    ActualTransferQueue m_queue; // Queue of transfers
};

#endif // _XFERQUEUE_H_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -