There isn't really a clear rule for it, as it's ref's call in most cases. In the last weeks, I've seen it called back if the ball is lost quickly and sometimes it isn't.
It tends to depend on retention of the ball, closeness to the opponent's goal, any advantage in numbers of attack vs defence.
It may depend on why the ball is subsequently lost - e.g. if a bad pass goes out of play, it's not to do with the offence, and shouldn't necessarily be pulled back. It won't be called back after more than 2-3 seconds.
The only thing in the laws is about applying bookings after advantage, and advice not to play advantage for a sending-off offence (2nd yellow, violent conduct, serious foul play - note, not for denial of goal-scoring opportunity).
Rugby advantage is very different depending on if it's a knock-on or penalty. A knock-on advantage will often ended very quickly, pretty much as soon as they've advanced downfield - that's the closest to a football advantage.
A rugby penalty advantage is the one that lasts much longer and tends to equate to a free play - there's no comparison between a penalty advantage in rugby and any advantage in football.