#include "fcgiid.h"
 
 // starting at 1
uint16_t FCGI_ID::getID()
{
 if (m_unused.empty()) {
  m_current_max++;
  return m_current_max;
 } else {
  uint16_t result{*m_unused.begin()};
  m_unused.erase(m_unused.begin());
  return result;
 }
}

void FCGI_ID::putID(uint16_t id)
{
 m_unused.insert(id);
}