1 ///////////////////////////////////////////////////////////////////////////////
2 // $Source: x:/prj/tech/libsrc/res/RCS/resarq.h $
4 // $Date: 1997/08/12 12:19:14 $
11 EXTERN
void LGAPI
ResARQClearPreload(Id id
);
13 #if defined(__ARQAPI_H) && defined(__cplusplus)
20 ///////////////////////////////////////////////////////////////////////////////
25 class cResARQFulfiller
: public IAsyncReadFulfiller
31 ///////////////////////////////////
36 ///////////////////////////////////
38 BOOL
Lock(Id id
, int priority
);
39 BOOL
Extract(Id id
, int priority
, void *buf
, long bufSize
);
41 BOOL
IsFulfilled(Id id
);
43 HRESULT
GetResult(Id id
, void **);
45 void ClearPreload(Id id
);
46 BOOL
IsAsynchronous();
48 ///////////////////////////////////
50 STDMETHOD (DoFulfill
)(const sARQRequest
*, sARQResult
*);
51 STDMETHOD (DoKill
)(const sARQRequest
*, BOOL fDiscard
);
53 DECLARE_UNAGGREGATABLE();
55 ///////////////////////////////////
60 class cResControlTable
: public cHashSet
<sResRequest
*, Id
*, cHashFunctions
>
63 virtual tHashSetKey
GetKey(tHashSetNode node
) const;
66 ///////////////////////////////////
68 // Asynchronous resource requests are tracked using a hash table of
69 // sResRequest structures
81 ///////////////////////////////
83 sResRequest(cResControlTable
& owningControlTable
,
84 Id id
, int priority
, eRequestKind kind
,
85 void * pBuf
= NULL
, long bufSize
= 0)
93 m_OwningControlTable(owningControlTable
)
95 m_OwningControlTable
.Insert(this);
100 Verify(m_OwningControlTable
.Remove(this));
103 memset(this, 0xfe, sizeof(sResRequest
));
106 ///////////////////////////////
108 IAsyncReadControl
* pControl
;
116 cResControlTable
& m_OwningControlTable
;
118 ///////////////////////////////
124 ///////////////////////////////////
126 BOOL
QueueRequest(Id id
, int priority
, sResRequest::eRequestKind
, void *buf
= NULL
, long bufSize
= 0);
127 HRESULT
SatisfyRequest(sResRequest
*, void **);
129 ///////////////////////////////////
131 IAsyncReadQueue
* m_pAsyncReadQueue
;
132 cResControlTable m_Controls
;
134 BOOL m_fSatisfyingPreload
;
138 ///////////////////////////////////////
140 inline BOOL
cResARQFulfiller::Lock(Id id
, int priority
)
142 return QueueRequest(id
, priority
, sResRequest::kLock
);
145 ///////////////////////////////////////
147 inline BOOL
cResARQFulfiller::Extract(Id id
, int priority
, void *buf
, long bufSize
)
149 return QueueRequest(id
, priority
, sResRequest::kExtract
, buf
, bufSize
);
152 ///////////////////////////////////////
154 inline BOOL
cResARQFulfiller::Preload(Id id
)
156 return QueueRequest(id
, kPriorityLowest
, sResRequest::kPreload
);
159 ///////////////////////////////////////
161 inline BOOL
cResARQFulfiller::IsAsynchronous()
163 return !!m_pAsyncReadQueue
;
166 ///////////////////////////////////////////////////////////////////////////////
173 #endif /* !__RESARQ_H */