3 #include "gdipp_lib/lock.h"
10 // TODO: change to blockingly wait until _busy.empty() is true
11 assert(_busy
.empty());
15 for (std::list
<HDC
>::const_iterator free_iter
= _free
.begin(); free_iter
!= _free
.end(); ++free_iter
)
17 b_ret
= DeleteDC(*free_iter
);
24 // acquire a resource from the pool
25 // if no resource exists, create one by calling create() of the template class
26 // otherwise, remove one from the free resource set and add to busy set
28 lock
l(lock::SERVER_DC_POOL
);
34 hdc
= CreateCompatibleDC(NULL
);
46 bool dc_pool::free(HDC hdc
)
48 // return claimed resource back to the pool
50 lock
l(lock::SERVER_DC_POOL
);
52 std::set
<HDC
>::const_iterator busy_iter
= _busy
.find(hdc
);
53 if (busy_iter
== _busy
.end())
56 _free
.push_back(*busy_iter
);
57 _busy
.erase(busy_iter
);