[mlpl] Reimplement SmartQueue with template.