The function
releases one thread (or all threads, if manual-reset)
which is/are waiting for the pulsed event, then returns the
event to the unset state.
If no threads happen to be waiting, then the event goes to
the unset state without anything happening.
And there's the flaw.
How do you know whether the thread that you think is waiting on
t...
Another type of higher-order enumeration is composition,
where one enumerator actually combines the results of
multiple enumerators.
(Everybody knows about derivation, but
composition is another powerful concept in
object-oriented programming.
We've seen it before when building context menus.)
In a producer-driven enumerator, you would implemen...
One type of higher-order enumeration is filtering,
where one enumerator takes the output of another
enumerator and removes some elements.
In a producer-driven enumerator, you would implement filtering
by substituting a new callback function that responds to callbacks
on behalf of the client for items that should be filtered,
and forwarding callb...
As we discovered in the previous two entries [second], the problem with enumeration is that somebody always loses.
Now we will use fibers to fight back. Before you decide to use fibers in your programs, make sure to read the dire warnings at the end of this article. My goal here is to show one use of fibers, not to say that fibers are the answer ...
Last time,
we looked at how a directory tree enumerator function
would have been written if the person writing the
enumerator (the producer)
got to write the spec. Now let's look at what
it would look like if the person consuming the enumerator
wrote the spec:
#include <windows.h>
#include <shlwapi.h>
#include <stdio.h>
#includ...
The COM model for enumeration (enumeration objects)
is biased towards making
life easy for the consumer and hard for the producer.
The enumeration object (producer)
needs to be structured as a state machine,
which can be quite onerous for complicated enumerators,
for example, tree walking or composite enumeration.
On the other hand, the callback...
When you set environment variables with the System control panel, the and variables are silently converted to their short file name equivalents (if possible). Why is that?
For compatibility, of course.
It is very common for batch files to assume that the paths referred to by the and environment variables do not contain any embedded space...
The CreateTimerQueueTimer function allows you to create
one-shot timers by passing
the WT_EXECUTEONLYONCE flag.
The documentation says that
you need to call
the DeleteTimerQueueTimer function
when you no longer need the timer.
Why do you need to clean up one-shot timers?
To answer this, I would like to introduce you to one of my
favorite rhe...
Still more ways of saying the same thing.
Why so many?
Because each was invented by different people
at different times to solve different problems.
BOOL is the oldest one. Its definition is simply
typedef int BOOL;
The C programming language uses "int" as its boolean type,
and Windows 1.0 was written back when C was the cool
languag...