00001 /* 00002 * Copyright (C) 2009, Edmundo Albuquerque de Souza e Silva. 00003 * 00004 * This file may be distributed under the terms of the Q Public License 00005 * as defined by Trolltech AS of Norway and appearing in the file 00006 * LICENSE.QPL included in the packaging of this file. 00007 * 00008 * THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING 00009 * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00010 * PURPOSE. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, 00011 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING 00012 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 00013 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 00014 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 00015 * 00016 * Thanks: Jose Renato Santos 00017 * 00018 */ 00019 00020 /////////////////////////////////////////////////////////////////////////////// 00021 // diskrequest.h: Definition of disk request structure and request 00022 // class: 00023 // - CRequestQueue 00024 // - CRequestFreeList 00025 /////////////////////////////////////////////////////////////////////////////// 00026 00027 #ifndef __DISKREQUEST_H_ 00028 #define __DISKREQUEST_H_ 00029 00030 00031 #include "vsitypesint.h" 00032 #include "localqueue.h" 00033 #include "Event.h" 00034 00035 const s32 DiskRequestStatusFree = 0; 00036 const s32 DiskRequestStatusInUse = 1; 00037 00038 00039 struct StrDiskRequest 00040 { 00041 StrDiskRequest* Next; 00042 StrDiskRequest* Previous; 00043 s32 Status; 00044 u32 Id; 00045 u32 StorageId; 00046 s32 Disk; 00047 u64 Pos; 00048 u32 Size; 00049 EventDataRequest* event; 00050 private: 00051 friend class CDiskRequestManager; 00052 }; 00053 00054 /////////////////////////////////////////////////////////////////////////////// 00055 class CDiskRequestQueue 00056 { 00057 public: 00058 // CDiskRequestQueue(); 00059 // ~CDiskRequestQueue(); 00060 void Put(StrDiskRequest *DiskRequest); // Put Request at end of queue 00061 StrDiskRequest* Get() ; // Get first element of queue. 00062 void Remove(StrDiskRequest *DiskRequest); // Remove arbitrary Request 00063 // from queue 00064 private: 00065 LocalQueue m_Queue; 00066 }; 00067 00068 /////////////////////////////////////////////////////////////////////////////// 00069 class CDiskRequestManager 00070 { 00071 public: 00072 CDiskRequestManager(); 00073 ~CDiskRequestManager(); 00074 int Initialize( const unsigned int nDiskRequests ); 00075 void Free( StrDiskRequest* DiskRequest );// Return DiskRequest to free list 00076 StrDiskRequest* New(); // Get new DiskRequest struct from 00077 // free list if available, 00078 // otherwise return null 00079 00080 StrDiskRequest* Get( const u32 ReqId );//Get address of DiskRequest struct. 00081 // for a given DiskRequest id 00082 private: 00083 unsigned int m_n; 00084 CDiskRequestQueue m_FreeList; 00085 StrDiskRequest* m_DiskRequest; 00086 }; 00087 00088 #endif // __DISKREQUEST_H_