I used to have similar dreams when I started my first job as a bagger at a natural foods co-op--I'd try to fall asleep, but my brain wouldn't stop strategically placing groceries in bags--and when I was a kid and would play a lot of Tetris on our first-edition, black and white screen Gameboy (this one--ah, that makes me feel old!).
Keeping in mind that I've struggled with insomnia for years and have sought out doctors and alternative practitioners galore to try to figure it out, imagine my surprise when a co-worker told me about Hypnagogia.
This particular co-worker has also struggled with insomnia and we've compared notes once in a while on our respective sleep idiosyncrasies. I was telling him about some severe, disturbing hallucinations I had recently (par for the course in insomnialand, unfortunately) that were paired with paralysis, and he immediately said "Hypnagogia." It's a phenomenon mostly related to when you're falling into and out of sleep, which is when most of my sleep problems occur. Take a look under the Sensory Phenomena heading (and yes, I realize Wikipedia is not the place to diagnose yourself, and I do see all those "citation needed"s in the article) and what do you see? For one, the "Tetris Effect":
People who have spent a long time at some repetitive activity before sleep, in particular one that is new to them, may find that it dominates their imagery as they grow drowsy, a tendency dubbed the Tetris effect. This effect has even been observed in amnesiacs who otherwise have no memory of the original activity. When the activity involves moving objects, as in the video game Tetris, the corresponding hypnagogic images too tend to be perceived as moving. The Tetris effect is not confined to visual imagery, but can manifest in other modalities also.
For another, "server dreams":
This is very common amongst new waiters or waitresses in busy restaurants where they report having "Server Dreams" and restlessly wait tables in this state of mind, sometimes jolting them fully awake or preventing them from transitioning into actual sleep.
This definitely explains a lot. In fact, I've experienced nearly all the phenomena--sleep paralysis, strange vibrations, hallucinations, visions, apparitional experiences, insight, amnesia, phosphenes--of Hypnagogia. I've involuntarily written entire screenplays in my head while in a state of sleep paralysis before.
Luckily, I don't really have server dreams anymore (but Amy Poehler does!). Occasionally I'll have a work-related stress dream, but I'm very thankful to have a job that doesn't intensify my (apparently) already cray-cray sleep issues.