2 * Copyright 2010, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
17 #include <kernel/util/DoublyLinkedList.h>
18 #include <Referenceable.h>
28 kMsgImageCacheImageLoaded
= 'icIL',
29 kMsgImageCacheProgressUpdate
= 'icPU'
33 class BitmapOwner
: public BReferenceable
{
35 BitmapOwner(BBitmap
* bitmap
);
36 virtual ~BitmapOwner();
43 struct CacheEntry
: DoublyLinkedListLinkImpl
<CacheEntry
> {
48 BitmapOwner
* bitmapOwner
;
57 virtual ~ImageCache();
58 status_t
RetrieveImage(const entry_ref
& ref
,
60 const BMessenger
* target
= NULL
);
65 static status_t
_QueueWorkerThread(void* self
);
67 status_t
_RetrieveImage(QueueEntry
* entry
,
69 void _NotifyListeners(CacheEntry
* entry
,
70 QueueEntry
* queueEntry
);
71 void _NotifyTarget(CacheEntry
* entry
,
72 const BMessenger
* target
);
73 void _BuildNotification(CacheEntry
* entry
,
77 typedef std::pair
<entry_ref
, int32
> ImageSelector
;
78 typedef std::map
<ImageSelector
, CacheEntry
*> CacheMap
;
79 typedef std::map
<ImageSelector
, QueueEntry
*> QueueMap
;
80 typedef std::deque
<QueueEntry
*> QueueDeque
;
81 typedef DoublyLinkedList
<CacheEntry
> CacheList
;
85 CacheList fCacheEntriesByAge
;
89 int32 fMaxThreadCount
;
96 #endif // IMAGE_CACHE_H