If you think about it this should not be a hard situation to handle (depending on many factors of course.) If all the gang members were unarmed ( I assume they were) you should be able to use deadly force on the ring leader, and most likely the rest will scatter. Of course you don't shoot until you know he's going to or is going to cause serious bodily harm.
Now if the rest don't flee then you'll have to tough it out or run. Personally, if I wasn't closed in I'd run. If you can't run, I'd take out a few more and run through where they were standing, get to the nearest phone and dial 911.
Of course if they don't scatter upon you using deadly force on the ringleader, your odds of surviving go down drastically. However there is still hope. These kinds of situations is why i still prefer Hi-cap 9mm's. More rounds can stop more targets, especially if you can shoot great with it.
Quite a lot of this is drivel.
If you consider 20 to 2 odds "not that hard", you need to have your head examined. "run through where they were standing"? Mob attacks do not have static lines like video games. They are "dynamic" to put it mildly. People coming at you from pretty much all directions, lots of noise, etc. If they are determined, or simply cracked out/methed up, they are not going to stop after a few rounds. Dealing with one cokehead has gotten many armed and trained cops killed. What makes you think you can take on 10 to one odds with cokeheads mixed in? Hell, where are you going to find the time to reload after that first mag runs dry? I'm betting there's at least one of them inside 21 feet, and that's plenty of time to close and club or shank you before you can get that next round on target. Reloads are great when you have COVER, or at least concealment. In the open against a determined mob in melee range, you are meat. The only time you will ever have a chance to reload is if you are barricaded in your home/car/shop/etc.
Dialing 911 from a payphone while getting mobbed will get you beat with that very phone for the 15 minutes minimum it will take them to respond to the call, if you can even get through to 911. I've waited for over 20 minutes on 911. Have you ever had occasion to use the dial-a-prayer system?
Also, out of a crowd of 20 thugs, I'm willing to bet at least one of them also has a firearm. While you're dealing with the 19 friends, that one has plenty of time to get all set to plug you. Odds are you won't even clearly see the gunman. Try to keep the fantasies out of the strategies and tactics forums, huh?
Your best choices are to 1. Run like hell, and 2. Run faster. If you are followed, and some of them have fallen behind, then, like you say, you might be able to pick off some leaders and retreat further. Even that, though presupposes you have some way to run in the first place. Any mob is a bad situation, and is best avoided.