Use open_list as FILO to adjust size of list. ( A new sm is pushed in front of the list by PreWarmQeueu::push() ) When the list has redundant sm(s), they will be closed by inactivity timeout. */
| 773 | When the list has redundant sm(s), they will be closed by inactivity timeout. |
| 774 | */ |
| 775 | PreWarmSM * |
| 776 | PreWarmQueue::dequeue(const PreWarm::SPtrConstDst &target) |
| 777 | { |
| 778 | PreWarmSM *sm = nullptr; |
| 779 | |
| 780 | auto res = _map.find(target); |
| 781 | if (res == _map.end()) { |
| 782 | // no such pool |
| 783 | return nullptr; |
| 784 | } |
| 785 | |
| 786 | const PreWarm::SPtrConstDst &dst = res->first; |
| 787 | Info &info = res->second; |
| 788 | |
| 789 | Queue *q = info.open_list; |
| 790 | while (!q->empty()) { |
| 791 | sm = q->front(); |
| 792 | q->pop_front(); |
| 793 | |
| 794 | if (sm->handler == &PreWarmSM::state_open) { |
| 795 | _cop_list.remove(sm); |
| 796 | break; |
| 797 | } |
| 798 | |
| 799 | _delete_prewarm_sm(sm); |
| 800 | sm = nullptr; |
| 801 | } |
| 802 | |
| 803 | // stat |
| 804 | if (sm == nullptr) { |
| 805 | ++info.stat.miss; |
| 806 | } else { |
| 807 | ++info.stat.hit; |
| 808 | } |
| 809 | |
| 810 | _prewarm_on_dequeue(dst, info); |
| 811 | |
| 812 | return sm; |
| 813 | } |
| 814 | |
| 815 | void |
| 816 | PreWarmQueue::_new_prewarm_sm(const PreWarm::SPtrConstDst &dst, const PreWarm::SPtrConstConf &conf, |