How does the game decide which units spawns next?

When at popcap buildings continue to produce units and hide them inside directly behind the doors waiting for their compatriots demises to step out on the battlefield.

How does the game decide which unit comes out next when dozens of buildings have units queued up?

Queued up first? Completely produced first?

I also did notice a problem getting out multi-pop siege when having many one-pop units queued up.
They take up the pop-space as soon as something dies.

But if a three-pop-unit dies will a three-pop unit that is build completely come out or the three one-pop-units that are in other buildings ready? Does then queued first or finished first strike?

Is that info available anywhere? I hadn’t had the time to check it out ingame.

It’s based on the order the buildings were built. Every time you build a building it is added to the end of the list. The game goes through that list in order from first to last when building units. Simply placing a building counts, you don’t need to start construction, any building placed before another will get priority.

If you have a 3 pop unit and 3 one pop units queued and you gain 3 population because a unit died then the units produced will be determined by which production buildings you placed first.