Spin-wave quantum computing with atoms in a single-mode cavity