The Old New Thing

Taxes: Hierarchical Storage Management

One of the taxes I alluded to some time ago when I broached the issues of software development "taxes" is Hierarchical Storage Management. The short description of Hierarchical Storage Management is that it is a way of archiving data transparently. When a file is due for archival, it is transferred to a slower (but less expensive) storage ...

Semaphores don’t have owners

Unlike mutexes and critical sections, semaphores don't have owners. They merely have counts. The ReleaseSemaphore function increases the count associated with a semaphore by the specified amount. (This increase might release waiting threads.) But the thread releasing the semaphore need not be the same one that claimed it originally. This ...

Take it easy on the automatic retries

When I saw a discussion of how to simulate retry via try/catch, using as inspiration a Ruby function that retried a network operation three times before finally giving up, I felt the need to caution against automatic retry. Your natural inclination when faced with a failure that has a good chance of being caused by a transient condition is ...

Why is there a special PostQuitMessage function?

Why is there a special PostQuitMessage function? Because it's not really a posted message. Commenter A. Skrobov asked, "What's the difference between and ?" They are not equivalent, though they may look that way at first glance. The differences are subtle but significant. Like the , , and messages, the message is not a "real" posted...

The COM interface contract rules exist for a reason

Some people believe that the COM rules on interfaces are needlessly strict. But the rules are there for a reason. Suppose you ship some interface in version N of your product. It's an internal interface, not documented to outsiders. Therefore, you are free to change it any time you want without having to worry about breaking ...

Quick and dirty buzzword bingo cards in Excel

Jensen Harris's brief example of using Excel's random number generator reminded me that I had need for the random number generator recently myself: Generating buzzword bingo cards. At the Battlestar Galactica party, our hosts needed to create some Battlestar Galactica-themed buzzword bingo cards and asked me to help out. Here's how I did ...

Thread affinity of user interface objects, part 5: Object clean-up

The window manager and GDI objects as a general rule will automatically destroy objects created by a process when that process terminates. (The window manager also destroys windows when their owner threads exit.) Note, however, that this is a safety net and not an excuse for you to leak resources in your own program with the attitude of "Oh, ...

Thread affinity of user interface objects, part 3: Menus, icons, cursors, and accelerator tables

The remaining user interface objects in common use are menus, icons, cursors, and accelerator tables. Menus do not have thread affinity. Any thread can use a menu. However, if two threads use a menu, it is the responsibility of those threads to coordinate among themselves how that menu will be used, so that one thread doesn't modify a menu ...