Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

The Mail Clerk and the Magic Ring

by chromatic (Archbishop)
on Dec 05, 2002 at 03:19 UTC ( #217662=note: print w/replies, xml ) Need Help??

in reply to Pipes? Child Processes?

Once upon a time, there was a little clerk who worked in a little post office. There wasn't much mail to sort, so he could take his time, doing one job at a time, until everything was finished.

Over time, more and more mail came in. Some of it had to be processed very quickly, and some of it took a long time to sort properly. He was only one clerk, though, so he could only sort one piece of mail at a time -- no matter how long it took. This didn't make his customers very happy. Before long, he was awash in complaints, which just gave him more to do.

The clerk decided to try an experiment. He would work for only a few moments on each piece of mail, then would switch to the next piece. He hoped this would prevent any one piece of mail from waiting too long to be sorted. Unfortunately, he could only do a certain amount of sorting in a day, and he was spending a lot of time switching between pieces of mail -- even touching some pieces of mail dozens of times before they were sorted.

Luckily, he had a magic ring. The ring had a very special power -- it could make a magic clone of the clerk in his office. There was one drawback, though. The clerk and the clone could not share their thoughts. The clerk had a great memory. He could remember every piece of mail he had sorted in a day. So could the clone. Neither could remember what the other had done, though.

The clerk tried the ring. It worked like, well, magic. He had a clone that would also process mail.

A few minutes later, the clerk realized that both he and his clone were working on the same pieces of mail. He decided that he would be better off chosing a piece of mail, creating a clone, and then switching to a new piece of mail.

That worked so well, he stopped sorting mail altogether. Instead, he created clones. Each clone would process one piece of mail and then disappear. He would keep track of which piece of mail he handed to the clone, and would know which mail had been processed.

There was one problem remaining. What would happen if there were a problem with the piece of mail? For example, some pieces of mail were missing names. Others had bad addresses. The clones would just stop before they disappeared, and the mail would not be sorted.

One option would be for the clone to put the piece of mail back in the pile if there were a problem. This was not good, though, because it would never be fixed. The clerk also did not have time to check each piece of mail himself to see if it had been sorted, as he was too busy using the magic ring to make clones and to make the clones disappear.

The clerk finally decided that he needed some way to talk to his clones, so he used the ring to give each clone a magic walkie-talkie. If a clone discovered that there was a problem with its piece of mail, it would report the problem back to the clerk, and he could make a note of it in his memory.

This was widely regarded as a good solution, and everyone was happy, except for the clerk's wife who had to make extra potatoes on the day when the clerk forgot to tell the clones to disappear after they had sorted their mail -- but that is a story for a different time.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://217662]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2018-07-21 11:55 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (448 votes). Check out past polls.