28.12.09

Review queue zero

Tags: , , , , — Jeff @ 16:00

I have zero outstanding review requests against me, placing me in a state in which I have not been since at least the first few months of the year. Yay! If you have review requests to make, and they could reasonably be addressed to me, feel free to do so. No one else is further ahead in that game than I am — for the moment. Carpe diem!

25.12.09

Merry Christmas!

As an expression of the festive holiday spirit, while being mindful of the current economy, I direct you to a timeless economics paper on The Deadweight Loss of Christmas by Joel Waldfogel.

Put simply, when it comes to gift-giving, the only person who knows precisely the value of a potential gift is its receiver. If the receiver values the gift at less than the value the giver expended to acquire it, we have deadweight loss: economic inefficiency present when allocation of goods is not Pareto optimal (that is, some other allocation would leave both parties better off). Had the giver instead given that same value in a more fungible form (the epitome of which is generally reached in cash), the receiver could have acquired the value present in the intended gift and the value present in the excess, thus maximizing his utility from the gift value. Where does that lost value in the excess go, if the inefficient gift is given? It is lost; neither giver nor receiver is fully satisfied. The giver overallocated his resources toward satisfying the receiver (or, if you prefer, allocated them in a way which did not maximize received value); the receiver’s utility was not maximized.

So, in the future (perhaps not this Christmas, but in future ones, or for birthdays, or for other times when you might ordinarily give presents), do your friends’ utility curves and your pocketbook a favor: give the gift of cash, the gift that will give them exactly what they want. (And, if you still think you know what your friends want better than they do, simply suggest the ways you think they would best maximize their utility while spending it. Another idea: give early to maximize net present value of the money, also allowing them to take advantage of fleeting sales that may no longer be available after Christmas or some other occasion.) You will increase the market efficiency of a baroque, inefficient ritual, and you will improve the economy in the most efficient manner while doing so.

Update: One comment directs me to today’s Dilbert strip, which expresses the above rather more pithily (particularly noting that gift-giving inefficiency is likely heightened for workplace gifts where deep knowledge of the other person’s desires is potentially less common). ๐Ÿ˜€

21.12.09

ECMA-262 ed. 5 backwards-incompatible change coming to SpiderMonkey and to Gecko-based browsers

(preemptive clarification: coming in Firefox 3.7 and not Firefox 3.6, which is to say, a good half year away from now rather than Real Soon Now)

ES5 and compatibility

The fifth edition of ECMA-262, the next iteration of the JavaScript language, is broadly backwards-compatible with existing JavaScript code. Generally, code that worked in past browsers that implemented the specification will continue to work in new browsers as they implement the new edition of the specification. However, there are a few exceptions. The most obvious one is ES5’s strict mode, where specially-tagged scripts and functions will cause parsing and execution of their contents to occur under stricter requirements than in the past. For example, this code would have executed “as intended” in ES3, but in ES5 the definition of a variable named “arguments” inside a function in strict mode is a syntax error (none of the code even executes):

function strictModeError()
{
  "use strict";
  var arguments = 17; // stupid, but permissible, in ES3
  return arguments;
}
if (strictModeError() !== 17)
  throw new Error("up is down");

The above isn’t more than a theoretical problem as it is expected old code wouldn’t have accidentally opted into strict mode. Not all of ES5’s incompatible changes, however, are so benign.

ES5 compatibility with ES3 extensions

One unusual area of compatibility concerns not ES3, but extensions to ES3. One of the more profound changes in ES5 is the introduction of getters and setters, in which what appears syntactically to be a property when used actually will invoke function calls “under the hood”. Most major JS engines support this extension to ES3:

var o =
  {
    get field() { return this._field; },
    set field(f)
    {
      if (typeof f != "number")
        throw new Error("not a number");
      this._field = f;
    },
    _field: 0
  };
print(o.field); // 0
o.field = 5;
print(o.field); // 5
try { o.field = "0"; } catch (e) { /* throws: not a number */ }
print(o.field); // 5
o.field = 17;
print(o.field); // 17

This syntax is in ES5, partly because it addresses a need in a reasonable way but mostly because many developers will already be familiar with it. (Getters and setters were also available programmatically; ES5’s solution is different but more flexible.) However, not all aspects of getters and setters are present in ES5 in the same way they were in extensions to ES3 engines.

Assigning to getter-only properties in ES5

Consider the previous example, slightly tweaked:

var o =
  {
    get field() { return this._field; },
    _field: 17
  };
print(o.field); // 17
o.field = 5;  // ???
print(o.field); // ???

In this case the field property is read-only: you could analogize it to element.childNodes.length, which has a value which it makes no sense to attempt to change. What should happen, then, if you attempt to change it? Current browsers throw a TypeError when you try this. ES5, however, chooses to remain (arguably) more faithful to ES3 and instead makes setting a property that only has a getter do nothing — except in strict mode, where a TypeError exception will be thrown.

SpiderMonkey, the JavaScript engine embedded in Gecko browsers, has just made the switch from its previous always-throw behavior to ES5’s only-throw-if-in-strict-mode behavior when an attempt is made to set a property that only has a getter. (This will also apply to DOM properties like the aforementioned element.childNodes.length.) In the future, if you try to set a property that only has a getter, no exception will be thrown unless you’ve opted into strict mode. This change is now in trunk builds of Firefox; download a nightly build from nightly.mozilla.org and test out the change for yourself (use the profile manager if you want to keep your current Firefox settings and install untouched). If your site relies on an exception being thrown, this change could break it, and we’re hoping that an extended period of time to test the change will help developers iron out any reliance on this non-standard behavior. This change will first appear in Firefox 3.7, which probably won’t be released until the second half of 2010 or so. Firefox 3.6 preserves current behavior where an exception is always thrown, so you should have plenty of time to update your site in response to this change.

The bottom line

Firefox 3.6 and earlier throw an exception whenever you attempt to set a property represented only by a getter (this includes DOM properties defined as readonly). Firefox 3.7 will only throw a TypeError when assigning to a property represented by only a getter if the assignment occurs in ES5 strict mode code. This change will also apply to attempts to set readonly DOM properties like element.childNodes.length. If you’re relying on an exception being thrown in either case, change the assignment location code so that it works when no TypeError exception is thrown.

20.12.09

Duncannon, PA to Bluemont, VA: because itโ€™s there

August 29

(25.9; 1067.0 total, 1107.0 to go; +10.9 from pace, -163.0 overall)

The restaurant across the street, Goodie’s, may open early, but I’m not in the mood to get an early start today, particularly with the sprinkly rain outside. Instead I sleep in a bit before picking up groceries and eating at the restaurant. While there I skim through the newspaper, discovering that Obama gave his nominee speech within the last couple days, finally becoming more than the presumptive nominee at the Kabuki dance that is a modern political party’s national convention.

In more interesting, less ceremonial news, I read through an article discussing the Amethyst Initiative: but first, a little background.

It is well-known that the national drinking age in the United States is 21; I will presume without evidence, however, that it is far less known that this is untrue. In reality there is no national drinking age in the United States. Rather, each and every state has determined its own drinking age to be 21. Independent determinations by the states? Evidence of settled scientific investigation? Lobbying by the Sons of the Women’s Christian Temperance Union? None of these reasons are accurate. (Okay, I haven’t really checked that the last possibility didn’t happen; I’ll bet a beer that it didn’t.)

The reason the states have universally adopted a drinking age of 21 is that Congress extorts the states to make 21 the minimum lower bound on the drinking age. In 1984 Congress passed the National Minimum Drinking Age Act, pursuant to which:

The Secretary shall withhold 10 per centum of the amount required to be apportioned to any State under each of sections 104 (b)(1), 104 (b)(3), and 104 (b)(4) of this title on the first day of each fiscal year after the second fiscal year beginning after September 30, 1985, in which the purchase or public possession in such State of any alcoholic beverage by a person who is less than twenty-one years of age is lawful.

23 U. S. C. ยง158. In plain English any state which has a drinking age under 21 loses 10% of its federal highway funds. Keep the limit at 21 or higher and you get all the money; lower it below that and you lose 10% of it. Congress did not have authority to pass a national drinking age directly (a plausibly-disputable assertion if one looks to Supreme Court precedents rather than to the Constitution itself, but suffice it to say that if Congress could duck the battle it would), so it instead brought about the same end result by coercing the states into doing it on their own; it made them an offer they couldn’t refuse. (This isn’t strictly what happened; a few states held out on immediately modifying their drinking ages, but all eventually caved. Also, Puerto Rico and the Virgin Islands, while not states, are apparently subject to the withholding, but both have a drinking age of 18 and apparently forego that 10% of funds as a result.) Smarmy, eh? This is the reason why, if you desire to see the drinking age changed, you’ll almost certainly have to make a national campaign of it rather than simply a statewide campaign.

Of course, the act raised serious constitutional questions with respect to the Tenth Amendment and the Twenty-First Amendment (the latter being dragged in, perhaps, because its language might plausibly constitute a grant of extra powers to the states). Does the federal government have the power to, to some extent, under certain interpretations of the proposed legislation, enact legislation outside the scope of its constitutionally-enumerated powers through coercion? It’s not a simple question, and it went to the Supreme Court in South Dakota v. Dole. (Also consider that there are other flavors of the question. For example, are fund grants conditioned on use in a specific manner fine, e.g. a fund grant for state police to use for anti-terrorist training? That hypothetical might seem much more reasonable, but how does it differ from the other scenario? Nailing down specific distinguishing factors is never easy, and there are many which might be reasonable to consider.) What’s the right answer to the question? I very much know what I want the answer to be with respect to the particulars of this situation: extorting the states this way is downright smarmy. Of course that doesn’t mean it’s constitutionally impermissible. There are many potential regulations which, properly examined, would be both constitutional and utterly abhorrent. I once thought the case was (unfortunately) correctly decided, but the more I read the less I believe I know enough to answer the question. It’s a research topic I’m going to have to investigate sometime, but here might be one potential starting point, from McCulloch v. Maryland, 17 U. S. 316, 423 (1819):

Should Congress, in the execution of its powers, adopt measures which are prohibited by the Constitution, or should Congress, under the pretext of executing its powers, pass laws for the accomplishment of objects not intrusted to the Government, it would become the painful duty of this tribunal, should a case requiring such a decision come before it, to say that such an act was not the law of the land.

(Hmm, I seem to have forgotten to return to the Amethyst Initiative, haven’t I? Basically, its goal is to start a dialog over whether the current “national” age limit is the best way to achieve the ostensible goal of the legislation: to keep “youthful” minds, and the people around them, safer. It doesn’t advocate a particular solution, but it recognizes that the current national age limit just doesn’t work: it’s too easy to get and consume alcohol if you’re underage. My thoughts on it are roughly these. First: I might have personally benefited from it, insofar as I might have been able to legally drink starting at an earlier age. Given my habits I’m sure the restriction would have made no difference in my safety, or that of others, because I’ve always been careful — not so much out of concern as out of proper enjoyment of the taste. Such enjoyment requires a very slow pace of consumption; it is at least plausible that if I drank at a normal pace, it would be impossible for me to make myself drunk. Further, since I stop after at most two or three glasses, I don’t think there’s much danger of my somehow losing self-control and unintentionally drinking faster. Moreover, I drink somewhat fitfully — usually a bottle or two of wine-equivalent a month. [And that’s now that I’m on a steady income; given my spending habits I have great difficulty believing I’d have consumed even that much in college if it were legal to do so.] Further throw in that I don’t own a car and either walk or bike now and in college, over short distances, and the overall danger from me seems negligible compared to the utility of occasionally being able to enjoy a drink. Second: this analysis probably doesn’t apply to very many people, unfortunately. Third: the legal prohibition now really isn’t, it’s wink wink, nudge nudge, say no more. Overall: Changing the current laws would have been an unqualified good for me. It would have also been good, and worse, for others. Given the failure of the current system, both practically and for lack of will to truly enforce it, and the good it prevents for those who are responsible, I think I would be in favor of loosening current restrictions at least to a point where the limit, at the very least for the “well-behaved” by some sort of legal evaluation, is 18. Harsher penalties for 18-20 when problems occur where alcohol is a factor would be fine, perhaps even recommended. It also comes down at least a little to Twenty-Sixth Amendment-style concerns: old enough to be in the army, old enough to vote, old enough to drink. Try reading about the experiences of Vietnam veterans during the war and upon return to America afterward; it’s pretty patently absurd.)

But anyway. With breakfast finished I head back across the street to the Doyle, where I pack up my things and leave minutes before checkout time at 11, saying good-bye to Silver Potato and Cracker and the Honeymooners on the way out. It’s still a little rainy, and neither couple feels like walking in rain. It’s somewhat tempting to stay longer, but I’m not in the right mental state to stop and drop an entire day here right now, particularly since it hasn’t been that much longer than a week since my last zero. Most other people take many more zeroes than I do, probably more than I could really bring myself to take even if I had no constraints on my time; I make up for it by taking longer, more frequent breaks when I’m hiking (hence why most stops at shelters are closer to an hour than to a couple minutes).

From here it’s a short bit of walking through the rest of the town before it’s back up on the ridges again. It’s not much of a walk to get to Cove Mountain Shelter, where I stop briefly to read the register and write a note in it recommending the jambalaya at the Doyle. The shelter has gnawed-smooth boards along the length of its porch, where a person might sit and let legs dangle; it’s clearly a prime spot for porcupines looking for salt to lick up from where sweaty hikers have sat.

Much of today’s hiking is uneventful. I make good time by not stopping much; after Cove Mountain it’s 7.3 miles to the next one with only a single road crossing for distance-estimation. The rain does stop eventually, but things stay generally pretty wet, and I can start to feel my feet rubbing against wet socks in a somewhat unpleasant way. The next shelter, Darlington Shelter, again has a register, and for the first time I see in it an advertisement for the Harpers Ferry Hostel that isn’t premature! Harpers Ferry is perhaps 110 miles south of here, which is a week or so south at a decent clip. It’s close enough now that one could imagine stopping once between here and there for food, then stopping in Harpers Ferry for a night — the key here being that it’s close enough to plan your next stop from here so that you’d reach Harpers Ferry at exactly the right time to stop. I’d have been fine seeing this ad as much as fifty or sixty miles back, too, but that first ad I saw for it perhaps 800 miles back, and all the others I’ve seen between there and here, are just too much.

I’ve gone 11.3 miles so far today at a reasonable clip, but from here south the trail becomes somewhat inhospitable as I pass through the Cumberland Valley. The valley is almost entirely covered with roads and large expanses of farmland, and there’s basically no cover anywhere. In fact camping is actually prohibited from Darlington south for 18.2 miles, except at a single place: Boiling Springs at 14.6 miles south, my target for the day if I don’t stop here (and there’s no way I’m doing that, not this short a day — were I to stop, I might as well have stayed in Duncannon). Back to the trail I go, heading south across the foggy valley.

A foggy day above Cumberland Valley
A foggy day above Cumberland Valley

The valley is definitely a change of pace from the usual ridge hiking to which I’ve become accustomed. Is it a good change? It’s really just a change. Many fewer people would hike the A.T. if it were like this the entire way; on the other hand, the A.T. really isn’t a trail of the wilderness. Anyone who hikes it now is never more than a few days from roads that head toward a grocery store or a place to stay off-trail; days of solitude are possible but uncommon. As one hiker grousedremarked in the register in Cable Gap Shelter in Georgia, no matter where you go you never have to wait long to hear an airplane passing nearby. Day hikers and weekend backpackers are common. The trail isn’t a hike outside of civilization, it’s a hike that skirts or runs amidst it. Today’s valley walk is, all things considered, par for the course — less wild than most parts but not at all unusual except in its sheer length.

Shortly after leaving the shelter I pass by the trailhead for the Tuscarora Trail, a side trail off the A.T. created years back when it was unclear that the official A.T. would remain fully accessible due to its passing over privately-owned land. The A.T. did eventually succeed with its occupied route, but the Tuscarora yet remains as an alternate path to travel between here and its southern end 185 miles south in Shenandoah National Park (if, admittedly, a less maintained path than the A.T. — we’re spoiled). A couple miles further on I pass by what is now the first underpass on the trail, going underneath Pa. 944. Construction finished up just over three months after I passed, so I wasn’t able to use it, but it was substantially excavated at that point. Crossing the road made it abundantly clear why the underpass was being installed: fast-moving traffic and low visibility in both directions due to a hill in one direction and a curve in the road in the other. At the moment this street view of the area shows the now-past construction, as well as overall visibility (traffic speed makes it worse than it might look):

View Larger Map
The A.T. crossing of Pa. 944, which became a functional underpass a few months after I passed by

A couple miles past that I hit an ATC work center, an organizing point for, I presume, work trips. I don’t stop for long, but the late start and my breaks today mean it’s past 18:00 by the time I leave to head south again, and I still have 10.6 miles of hiking until I can camp legally. I foresee night hiking in my immediate future; good times.

The rest of the day’s hiking proceeds uneventfully, the last couple hours or so of it in darkness. Once after dark I see what I think is a skunk twenty feet or so up the trail; it turns around and heads the other way down the trail as I (cautiously) follow it. By the time I reach Boiling Springs it’s approaching 22:00; ideally I’d have arrived earlier and gotten something to eat in town, but now it’s late enough that I don’t really feel like walking a couple tenths of a mile off-trail and finding out they’re closed or effectively so. Boiling Springs has an ATC office at which I fill up water bottles from an outside spigot the Companion mentioned, but otherwise I’m in and out of town without stopping, a few tenths of a mile south past some train tracks to a small field with an outhouse (present Memorial Day to Labor Day, so I’m just in under the wire!) where camping’s permitted. The Companion warns that, “The trains do run past here all night long”, and for a moment I’m not sure what it means, until a train passes by. This field is right next to the tracks, and that train’s loud. Here’s hoping I can sleep well with this racket…

August 30

(19.1; 1086.1 total, 1087.9 to go; +4.1 from pace, -158.9 overall)

I’d sort of intended to wake up semi-early to get into town to eat a full meal, but when push comes to shove in the morning I choose sleep over food. Rather, I try to; I must have slept through many trains throughout the night, but the ones passing by this morning are all more than loud enough to prevent me from really enjoying those extra minutes of rest. My feet, which felt a bit waterlogged yesterday and prone to blistering, are feeling about the same today, and my socks didn’t dry out enough overnight to really help matters. None of this bodes well for attempting the Four State Challenge when I reach the border in a few days or so. Still, that’s awhile off; we’ll see what happens before then.

Today’s hiking passes mostly in a blur. My feet continue to be red and irritated all day from excess moisture, but hiking goes reasonably, if slowly. After 10.5 miles, however, it’s time to stop — for ice cream! I’m within spitting distance of the halfway point on the trail, which means it’s time for the Half Gallon Challenge, a thru-hiker tradition involving ice cream whose name explains itself. I get a deli sandwich, a half gallon of ice cream, and a pop before moving on. It’s fairly late in the afternoon, but I know I’m not going to make it to Pine Grove Furnace State Park, my goal for the day, in time to visit the store there to complete the challenge, at least not if I don’t want to wait around until opening time tomorrow. Now a half gallon really isn’t a challenge for me, and I’ve eaten several so far on the trail, but today I make the mistake of eating my sandwich before eating the ice cream, with the result that I’m stuffed way before the ice cream is gone. I eat about two-thirds of it before deciding, regretfully, that I can’t finish it if I’m going to make it to Pine Grove before it gets too dark — an important concern because I’m staying at a hostel by the park, not camping near the trail, and it does have particular hours. As I head back to the trail I notice a newspaper stand, glance at it and walk the other direction, then do a double take: McCain picked who to be his vice presidential candidate? Wow. I’d heard Palin mentioned as a plausible choice but only as a dark horse pick. This could get really interesting, really fast.

The remaining ten miles pass quickly as I finally start to hit a good pace. A mile or so before the park I pass by the trail’s halfway marker:

The A.T. halfway marker
The A.T. halfway marker

The marker has been here for several years; it’s not really the halfway point now — the exact point changes from year to year with trail relocations and adjustments — but it’s only a handful of miles off. It’s close to 20:00 now, so I snap a few pictures (all of which turn out about as well as this one, except that this one had the best aim) and hurry on. The park technically closes at dark, so I’m going to be pushing it when I get in. Twenty minutes later or so I reach the park and, after a little stumbling around, find the hostel. The building was part of the Underground Railroad at one time, and it has a hidden basement where passengers would hide — reminds me of some of the spaces above ceilings and between floors in buildings at MIT. (Or so others tell me.) The hostel currently lacks laundry detergent, so it looks like I’m not going to be getting fully clean tonight. I still take a shower and hop into clean clothes for the night, after which I call home, catch up on email and read a few news articles, and head to sleep for the night.

August 31

(17.3; 1103.4 total, 1070.6 to go; +2.3 from pace, -156.6 overall)

It’s up and out this morning after too little sleep, but down the trail I go again. Hiking goes slowly as I pass the current midpoint of the A.T. somewhere a couple miles south of the hostel; I keep feeling like I should stop and doze off for a bit, which I eventually do for an hour or so — it helps. (However, the nap doesn’t do anything for my feet, which are still a bit raw and blister-prone but not so bad that I’m going to consider extra rest.) I’m in better shape after that and start making good time heading south, passing by Tom’s Run Shelter shortly after. I stop to read registers (there are two of them, because this shelter is actually two — each maybe eight feet by eight feet, separated by maybe fifty feet or so) and watch a butterfly move around and fly onto my backpack for a bit. I take several pictures in order to get it mid-flap with its full colors showing; it’s just fast enough and my camera is just slow enough to make this tricky:

A colorful butterfly in mid-flap, perched on my red Nalgene stowed in the mesh side pocket of my backpack, which leans against the wall of the shelter
A butterfly in mid-flap; the timing was actually kind of hard to pull off with my camera

I write an entry with some minor election commentary now that I’m caught up on world events, something snarky as I recall, before heading on again. After some uneventful walking I stop again at Birch Run Shelter for a break, just short of ten miles into the day; the shelter here is ridiculous. Imagine a small one-room log cabin, move one of the walls inward far enough to comfortably fit a picnic table, cut a door opening in that wall, then fill the inside with bunk space for eight people (more if people sleep on the floor, and more if you add in the porch). The wood all appears recently treated with polyurethane and other niceties; it’s nothing like most other shelters where the wood is treated, maybe painted, and hauled out to install. I’m now into Potomac Appalachian Trail Club territory, and the shelters here are either insanely awesome or fairly old but well-designed and amazingly well-maintained. It’s good enough that I’ve occasionally heard murmurings from other people that the club is too well-funded — an enviable position to be in, I’m sure. I stop long enough to write an entry in the register, but I need to keep moving both because it’s too early to stop and because it’s clear this shelter and the surrounding camping area are going to be very crowded tonight (there are nearly a dozen people here already, and there are still a few hours left of daylight for hiking).

The rest of the day’s hiking proceeds quickly and purposefully as I keep moving to ensure I have a reasonable amount of daylight at its end. It’s also worth noting that an early arrival means more time to sleep tonight. If I’m to attempt the Four State Challenge I really want to be as rested as possible the day before it, which means I get a lot of sleep tonight, finish the remaining twenty-odd miles to the Pennsylvania-Maryland border tomorrow as quickly as possible, eat a good dinner, and head to sleep. It’s a long walk, and I’m going to aim to be up sometime in the first three hours of the day — ugh — so I can keep to a comfortable pace and so I can visit the ATC office for the traditional mid-hike photo. I arrive in a fair amount of daylight, although the sun is mostly hidden at this point. Quarry Gap Shelters are another crazy spot: two small concrete log-cabin-styled shelters, with a concrete pad between them and a picnic table on it for cooking (and even a tarp that can be hung across the back to break the wind). A pocket on the trail-north shelter’s wall even contains board games for people to play! It’s an old shelter, dating to 1935, but it feels amazingly new and amazingly awesome. The PATC really does have too much time and money on its hands. ๐Ÿ˜‰

This shelter’s not as crowded as Birch Run was, but it’s pretty full. I’m the only thru-hiker, but there are other backpackers and a family there too. The backpackers are two middle-aged-ish women from Massachusetts or Connecticut (and the AMC; they tell me they thru-hiked the A.T. years ago and are just out doing a short trip now. I mention I’m going to attempt the Four State Challenge when they ask about my plans; they say they did it at a much more leisurely pace, perhaps not even breaking twenty miles in a day (and definitely any day even approaching that was a long, restless, painful day). I take advantage of their presence to complain about the lack of signage at the MACT border and show my pictures of what I thought was the border. It turns out the bark removal wasn’t supposed to have happened, but they do say the border is intentionally not marked well to discourage campfires just over the border into Connecticut (which forbids campfires at least on the A.T.), close enough that their prohibition doesn’t have much meaning if you can pinpoint the border and put your fire a few feet over it. They attempt to rationalize the campfire prohibition in various ways, but I remain thoroughly unconvinced. So the ground becomes sterile — so what? If you limit it to established campsites and rings only, you’re having the fires in places which have a fairly permanent impact on the area already! A little more at the edge of a well-established existing site would concentrate the impact in one location (a key principle of Leave No Trace). If you limit to rings only, that greatly minimizes the danger of a fire spreading out of control onto neighboring (private) land. Finally, campfires are an intrinsic part of camping. They may be a bit harsh on a few square yards of land (and to a lesser extent on the surrounding couple acres for dead limbs for fuel, but the relevant areas are forested and fuel would be plentiful), but that doesn’t mean the only proper response is a draconian ban on them entirely. Sigh; I’m glad I don’t live near Connecticut trail, even if I never started a campfire while thru-hiking and have difficulty even imagining a situation on the trail where I might.

Kids from a family staying for the night are rather loud, and one of the women has to yell over to the other shelter to ask for quiet, but I read late enough that I don’t have a problem with noise or getting to sleep. It’s 20.5 miles to the border plus whatever I need to do a little bit of resupply: I’m running low on food and snacks, and I want enough to get to Bear’s Den Hostel, which is a dozen miles after the Four State Challenge ends. I plan to do most of that tomorrow to get as close as possible to the border so the most epic day of backpacking I’ve ever considered doesn’t have extra mileage tacked on at the beginning rather than the end. We’ll see what happens and how easy or hard it actually ends up being…

September 1

(19.9; 1123.3 total, 1050.7 to go; +4.9 from pace, -151.7 overall)

Labor Day!

I’ve been a little worried about today being Labor Day, what with my plan to attempt the Four State Challenge tomorrow, as I don’t have the supplies to do it without visiting a grocery store. Will I be able to find a grocery store open today, at the time I reach it? Probably, since Labor Day isn’t one of the huge-name holidays, but it’s still a potential wrinkle, and given that I’m twenty miles from the border I don’t have a lot of margin for error. It’s not far from the shelter to Caledonia State Park, which presumably will have a ranger or two around to ask, so at least I’ll be able to find out early enough in the day to go further out of my way if necessary. I’m betting the store 0.7 miles west of the park will be open, but you never know.

It’s not much of a walk to get to the park, which is full of people picnicking and enjoying the day. A few people at a picnic table say hi and ask about my hiking plans. They tell me they’re from the nearby Waynesboro Senior Center, out for the holiday, and I answer some of their questions in return. They also offer me some of their food, which is mostly standard picnic fare with perhaps a little tilt towards sweets; I eat a couple doughnuts, some fruit salad, and a couple sandwiches made from the fixings they have, and they give me a doughnut or two “for the road”, as it were. They’re very oversupplied for the number of people they have, and they’re more than happy to see it be put to good use. I dally for a good length of time before deciding I really do have to move on, as I have 17 miles or so to get close to the border today and not much time after that to get some sleep before a long day with night hiking to start it. A brief search takes me to the park headquarters, where a ranger confirms that the store down the road is indeed open (although perhaps with slightly curtailed hours, not a problem for me), so I head off to it and resupply. I spend a little time at the store eating the remaining doughnuts and getting a little food and water in me before walking back to the trail to head south again.

The next few miles on the trail pass slowly. I didn’t get very much in the way of supplies since I only need it for a couple days, so it’s really just my normal early-day hiking funk. Some people hike strong in the morning and early part of the day; I’m just the opposite. I stop for a second by the trail to Rocky Mountain Shelters to polish off the rest of a loaf of raisin bread I bought at the store, hoping that maybe a little more delay and a little more energy will help me move faster. It doesn’t, but maybe a mile south I reach something that does — or rather, that something reaches me: the Honeymooners again! There’s nothing like putting someone in front of you on the trail to motivate you to keep hiking — kind of like the mechanical rabbits in dog races. The miles start flying now; we pass by Tumbling Run Shelters without a stop, heading toward Antietam Shelter. I stop at a road crossing to refill on water from a nearby stream, since it sounds like Antietam’s water is off-trail slightly, and continue on working to catch up to the Honeymooners. I do, eventually, at Antietam, where I discover they’re stopping for the day. Deer Lick Shelters aren’t much further down the trail, and they can be reached before dark, but they’re stopping earlier (and why not, since they’re probably at twenty miles for the day now anyway). I mention my intent to complete the Four State Challenge, and they wish me luck. Jessica cringes in horror at the idea, enough that it’s clear it was never in their plans even as a possibility. ๐Ÿ™‚

A short bit more hiking takes me to Deer Lick Shelters, the last shelter(s) in Pennsylvania and the last paired shelter I remember on the trail. It’s possible I just missed ones further south, but I’m guessing this is some sort of weird Pennsylvania thing. I stop, mention my plans in the register (I hardly expect to spend time doing so in any of the shelters in Maryland tomorrow), and move on. The remaining miles go well as I race dusk to get close enough to the border to stop. Eventually, at what I estimate is about half a mile short of the border, I cross a stream where I refill water bottles and find a small spot that appears perfect for campfires (although I see no burned material to indicate it’s been used as such recently), just as it gets dark. I don’t need much tonight beyond a somewhat comfy place to use a bivy sack, especially since I plan to wake up no more than a couple hours after midnight (!) to start the day’s hiking, and it’ll do fine. Two Knorr dinners later (I figure I need the energy, and it won’t hurt to reduce pack weight a little), it’s off to sleep, I believe after 22:00 — so much for finishing quickly and getting lots of rest before tomorrow. I set my watch alarm for 00:45, put it right next to my head, and pray that I’ll actually wake up to it. Too tired…

September 2

(51.0; 1174.3 total, 999.7 to go; +36.0 from pace, -115.7 overall)

I wake up on time to my alarm, thankfully, and mentally I’m in the right state to not unthinkingly roll over and back to sleep. It is so very tempting to rationally decide to sleep some more — but I could never forgive myself if I didn’t even make an attempt to complete the Four State Challenge the one chance I’ll probably ever have to try. I get up, pack up my sleeping bag and bivy sack, polish off a Pop-Tart, and start hiking south. It’s 1:15, and I am officially insane to be doing this.

I’m still in Pennsylvania now, but not for long — it’s only 0.6 miles to the Mason-Dixon line traditionally dividing South from North and officially dividing Pennsylvania from Maryland. Goodbye and good riddance to Pennsylvania and the Pennsylvania Rocks! I like to see something at a state border, and while what’s here isn’t much, at least there’s something:

The Mason-Dixon line marker
The Mason-Dixon line marker

The marker’s clearly seen better days, but it’s there and visible: I know exactly where it is and where I am in relation to it. From what I understand it was vandalized even worse shortly after I passed it (assuming my understanding of the description I received doesn’t simply describe the state in the picture), to the point where it wasn’t even there, so I’m glad I got there when there was something to see and note my progress. Shortly after I reach Pen Mar County Park, where I had intended to drop off my meager trash but promptly forget to do so now. There’s a nice view off over the surrounding countryside and its nighttime lights, but I move on without stopping very long.

Shortly after this I discover that the Pennsylvania Rocks! don’t end when you leave Pennsylvania; they actually continue down through much of Maryland, more or less petering out shortly into Virginia. On the plus side, I have to take a nice, relaxing pace over them to avoid stupid injuries, so it’s sort of a nice warmup for the day, since when it’s light I’ll need to keep a consistently good pace if I want to make the ATC office before it closes. Shortly after I discover that, oddly, I’m not the only person out and about now, as I pass a guy camping by a campfire, still awake, who’s awake enough to ask me questions when he sees me coming. This is more than a bit puzzling. First, overnight camping is allowed only at designated sites, so what’s he doing just off the trail here? Second, a campfire, at 2:00? Really? Really?

The trail moves along from here reasonably well. I pass a shelter, stop for water at a small stream I have to cross in a section of trail marked as somewhat fragile due to it passing near a watershed used for drinking water (or so I recall), and pass another shelter as darkness reigns at this early time in the morning. I hike through fields as dawn arrives, leaving a good half hour or so of change from nighttime darkness to visible light on the horizon. By 6:30 it’s bright enough to hike without my head lamp any more.

Now is when things start to get difficult. The trail is still rocky, but the sun’s coming out to make things much easier. Unfortunately, now is when lack of sleep starts to catch up to me, and for the next hour or so my pace is slow, and I don’t feel like I’m moving quickly enough. Moreover, it’s now perhaps 7:15, and I judge myself to be at about 1135 miles overall — but the ATC office that I have to reach by 17:00 is at about 1165 miles. My good pace is three miles an hour, but even if I hike at that pace constantly the rest of the way I wouldn’t make it in time. I feel an insistent temptation to drop the pack for a second, sit down, and lean back for a minute. However, I know this: the moment I do that, I can write off the Four State Challenge. In my current state it probably wouldn’t even take me a minute to fall asleep, and I don’t have the time to spare for a nap even if I could successfully limit myself to some particular duration. By sheer willpower I keep moving and keep hiking. I’ve thought about this since then, and I say this: choosing to keep moving at that point, fighting exhaustion and a seemingly unfeasible schedule, was the most difficult short-term decision I’ve ever made in my life.

Remember that saying, “Never judge a man until you’ve walked a day in his shoes”? (It’s actually “mile” rather than “day”, apparently, but the mangled version is what springs most readily to my mind.) I think if you want to judge me you will have to walk this day — all 51 miles of it, at the same pace I walked it, with the same stops I took. And you will feel pain, and you will feel exhaustion, and you will fight against instinct and against everything you know you want to do to achieve a goal that is of absolutely no intrinsic value whatsoever, and you will keep working towards this meaningless goal for no reason other than because you have chosen to do so. You will hate it, but you will keep doing it, and you would do it the same way if you had the chance to go back in time and do it differently. Then, and only then, can you judge me.

That decision marks a turning point for the entire day. If I’m going to keep moving, and if I’m going to make it to Harpers Ferry and the ATC office before it closes, I must speed up, so I do, probably to three miles an hour or so now. A little further I reach Pine Knob Shelter; I don’t really want to stop, but there’s an extremely convenient privy, so I head over just long enough to use it before moving on (not even visiting the shelter proper; I know what will happen if I stop at it just to look at the register for a second). Now’s when I really start picking up the pace as I pass over I-70, and I start easily making three-plus an hour. I’ve usually mentally kept track of upcoming landmarks in tenths of a mile to gauge progress; I stop doing that now and switch into full-out hiking mode. I pass by the Washington Monument (not that one) without stopping even long enough to see it; the closest I get are glancing at the illustrative signs on the trail up to it, as I head toward the parking lot of the park. I’m hoping to refill on water, but the faucets don’t seem to be running, so it’s keep-on-moving time. From now until Harpers Ferry, I hike almost without stopping, except that about every hour I reach behind me to pull out a large candy bar, snarf it down, pull out my Nalgene, stop only long enough to get a gulp of water without getting it all over myself, then start walking again as I close it up and put it back in place. I do make one exception for Dahlgren Backpack Campground which, bizarrely enough, has a restroom facility with showers (too bad I can’t stop for a night here to use them), both to refill on water and to dump the trash I forgot to dump at Pen Mar. Otherwise it’s continuous hiking, mile after mile, past views and shelters large and small, without stop except for swallows of water — not even for a lunch.

After many rocks and minor elevation changes of perhaps a thousand feet either way, I finally reach what was originally the C&O Canal Towpath, the last real milestone before Harpers Ferry. (The towpath is now a bike/hiking path chiefly due to a protest walk of it by William Douglas, the only Supreme Court Justice to walk the entire Appalachian Trail [in his case by a section-hike that concluded in 1958].) By now it’s somewhere around 15:30-16:00 or so, and with 3.5 miles remaining, and most of that on the flat towpath, I can tentatively assume victory in my attempt to reach the ATC office before it closes. Nevertheless I don’t slow my pace for fear that in doing so I will slow down too much and be unable to increase speed again, and in the end I reach the ATC office by about 16:35. By my estimation, since the turning point around 7:15 or so this morning, I have sustained an average pace of 3.6 miles, and I can feel every bit of that 0.6 miles an hour above the top pace I can comfortably sustain.

I thought I was the only southbounder ahead for a bit, but it turns out I’m not alone at the office — Smoothie is here! I haven’t seen him since Bald Mountain Brook Lean-To, just south of Monson — 1030 miles ago (!). We catch up for a bit — I find out that Colin, now known as Carat, whom I last saw at the same time I last saw Smoothie, unknowingly contracted — wait for it — dysentery. (I thought we were hiking the Appalachian Trail, not The Oregon Trail!) Apparently he went to a hospital three times before it was correctly diagnosed (the first two times they said it was just normal diarrhea, the third time apparently his liver was close to shutting down [!]), and now he’s way back on the trail from taking a couple weeks off from hiking. Smoothie and I aren’t sure how he managed to get it, since he was using Polar-PUR on his water as regularly as I’ve been using it. Speaking of water treatment, Smoothie hasn’t been treating quite so regularly, and he’s managed to get a bit of giardia (read: explosive diarrhea); it’s nothing antibiotics can’t treat, but the infection doesn’t just wear off immediately, so he’s stuck with it for awhile. I dash off a post noting my efforts for the day and try to catch up a little bit on email and such before heading south again. Smoothie heads into town to get something to eat, but it’s too far of a walk for me, so I leave the office later than he does but end up ahead of him on the trail.

From here, to technically complete the challenge, it’s apparently only 1.9 miles. The Companion’s descriptions and the way the trail lies make it a bit confusing, so where I thought I had 5.8 miles to the state line it’s really much less. Still, I’ve set out thinking otherwise, so I’m going to aim for 5.8 miles. Also, hey, why not? If I go only three miles past 5.8 miles I’ll hit the David Lesser Shelter, surely more comfortable than just sleeping some random spot off the trail. Plus, as a bonus, that’ll put me over fifty miles for the day. When will I ever come close to walking that far in a day again? I have to try for it. Meaningless goals: I strive for them. ๐Ÿ™‚

I expected to be hiking more slowly after such a long break, not to mention after such over-exertion before, and I’m not disappointed, as my pace slows to two, maybe two and a half miles an hour. It slowly turns dark as I keep on hiking, and eventually it hits full nighttime. By 20:00 my hiking is more stumbling than walking; I’m sure anyone who could see me now would think I was drunk. The single line of What Do You Do With a Drunken Sailor that I know (hint: it starts with “what” and ends with “sailor”) plays in my mind as I walk. I pass the road that marks what I originally thought was the border — three miles to go! I continue stumbling south looking for the turnoff to the east that marks the shelter, watching an incredible number of deer standing in the woods watching me pass by. I can see them almost entirely by the reflections in their eyes; is my head lamp the physiological equivalent of headlights to them? At 22:15 I finally reach the shelter; I could walk further, but the next shelter is three miles away. 51 miles ought to be enough for anyone. (The funny thing is, if the next shelter didn’t have a caretaker I probably would have headed for it, to reach the equally empty goal of walking two marathons. ๐Ÿ™‚ ) I’d hoped it would be empty, but it turns out there’s one other person, and when I see he’s awake I hastily apologize and say I’ll be asleep quickly and quietly. Indeed it is so — and thus ends the most epic day of backpacking ever. 51.0! +36.0!

This is the stupidest thing I’ve ever done in my entire life. ๐Ÿ˜€

September 3

(11.1; 1185.4 total, 988.6 to go; -3.9 from pace, -119.6 overall)

I am understandably in no rush to hike today, so I don’t set my watch alarm and I roll back over when I first wake up. The shelter’s empty; last night’s occupant must have left already (not surprisingly, given that it’s easily 9:30 or 10 by now). I pull out a Pop-Tart and eat it while reading through the register; I make my entry noting 51 miles yesterday (which I end with the sentence “RRRAAAWWRRRR!!!” [letter and symbol repetitions approximate]) and see Rock Layer’s entry noting his 60-mile day. It’s late morning by the time I head out, but it doesn’t matter: I’m not going any farther than Bears Den, a hostel and trail center just adjacent to the trail 11.1 miles south of here. Even if I take six or seven hours I’ll still be there well before 18:00, and even in my partially hobbled state I believe I can do better.

The first stop is a place that would have been a reasonable goal for yesterday if I had kept up my pace from before the ATC office or if I’d stopped for a shorter period of time: Blackburn Trail Center. It’s another PATC facility, and it has two buildings that serve as a summer caretaker’s home plus a smaller bunk house for hikers. The caretaker when I passed through apparently made spaghetti for hikers around dinnertime as well, so it would have been a great place to visit. However, none of that’s possible if you arrive as late as I would have, so in my position it makes much more sense to stop today rather than yesterday. I arrive and wander around the porch for a bit before finding a seat to read the register; the caretaker shows up and offers me a can of generic-brand Dr. Thunder (one guess what it tastes like), which I’m more than willing to accept. I spend a couple hours lazing around, reading and enjoying the pop, before deciding it’s time to move on again. My time isn’t entirely unlimited even if I can afford to move slowly.

South of Blackburn I encounter the “Roller Coaster”, a 13.5 mile section of trail with ten ascents and ten descents, nearly all of them lacking in views. The trail corridor’s particularly narrow here, so there wasn’t much freedom to hike around them or to provide any views. I hear one claim that the “undisclosed location” Cheney went to after 9-11 is very close to here, which would certainly explain the inflexibility if it’s true. None of it’s particularly strenuous, but it’s not really what I had in mind as what I wanted to do after yesterday.

A sign with these words on it: Hiker Notice Warning!  You are about to enter the Roller Coaster!!  Built and maintained by "Trailboss" and his merry crew of volunteers.  Have a great ride and we will see you at the Blackburn Trail Center (if you survive)
Announcing the Roller Coaster (sign at south end, actually seen September 5 rather than today, but it fits better today)

The above photo is from the south end of the Roller Coaster, two days later, positioned for northbound viewing; as usual southbounders get the shaft. Also discovered while taking this picture: my camera has zoom functionality! Who knew? I could have used that when I saw the rattlesnake in Connecticut.

Hiking drags on; I’m not really exhausted so much as just beat up. It’s a good thing today’s a short day. The stop a few tenths of a mile from Bears Den, however, provides some motivation to keep moving: the Horseshoe Curve Restaurant, with the claim of generous portions and a magical creation called “surge” Guinness that ostensibly recreates the effect of Guinness on tap without it actually being on tap. The food and Guinness are both tasty (although it seemed to me the Guinness wasn’t as magical as the shelter register ravings that preceded it claimed it to be), a nice meal before heading the last several tenths of a mile to Bears Den Hostel, perhaps a mile or two from Bluemont, VA.

The Bears Den hostel is run by two hikers, Red Wing and Hopeful, thru-hikers from last year; they also have a daughter/toddler Lydia (nicknamed Hikelet). The basic package deal is $25 for a night’s stay, shower, a cook-it-yourself frozen pizza for dinner (using the upstairs kitchen), and whatever pancakes you’re willing to make for yourself in the morning: a nice package, all around. Smoothie’s here; it sounds like he passed me when I stopped off at Blackburn Trail Center today. There’s also one more hiker whose name I don’t remember. I cook my pizza and pick up a few supplies for the next few days of hiking. It’s only a couple days from here to Shenandoah National Park; the trail there roughly follows the 100ish-mile Skyline Drive and passes near a handful of “waysides” with food and some camping supplies. My plan is to stop at one as my next resupply point, so I don’t need much (besides which I still have a handful of food items left that would get me another day or two anyway). Smoothie and I talk to Red Wing for a bit as we eat dinner before heading back downstairs for the rest of the night. Tonight’s somewhere in the Republican National Convention, and the speeches are all on TV. A few of us sit and watch Palin’s speech, which seemed to be a reasonable political speech as far as I could tell, although at its core it was still a political speech rather than in-depth policy examinations. (At a certain level a well-executed speech is a pleasure to watch, but for the most part I find speeches far less interesting than in-depth policy analyses. It’s a shame speeches get more coverage than policy, although to be sure it’s a rational decision for media organizations.) I take the opportunity to call home after seeing in email that family has decided to book a trip around September 10 and try to catch me wherever I happen to be; we settle on my meeting them at the south end of Shenandoah (roughly 140 miles south of here, which assumes I travel roughly twenty miles a day until then, easily doable). Finally it’s off to sleep for the night — the short day today should hopefully have me in good shape for tomorrow.

At this point I’m now fairly close to the head of the pack of people heading south for extended distances. Consequently, unless I know someone’s immediately in front of me, I’m going to be hiking alone for the most part from now on. I’m going to keep the decent pace I’ve been setting recently, for the most part, but if I feel like I need a break I’m going to stop and take one, and while I will likely push myself to get in decent mileage each day I’m not going to push too hard. These are the names I remember of long-distance hikers (most thru-hikers, some not) who are ahead of me:

  • Mango and Grettle, Cubby, Spoon, and Santana (started a week or so earlier than me in June, never met, several days ahead)
  • Moose, Duckie, Turbo (briefly met/passed by them around New Hampshire/Vermont, several days ahead)
  • Kim-Ki Jun, Korean SOBO (as he names himself in register entries, all of which are signatures more than expressive entries, to be sure, close enough to catch but will take some time)
  • Medicine Man (moving fast last I saw him in Vermont, over a week ahead back at 501 Shelter, very unlikely to catch up)
  • Flashdance (moving super-fast, way ahead of me, won’t catch up)
  • Rock Layer (also super-fast and won’t catch up)
  • Solo (name noticed only more recently in registers, but far enough ahead I’m unlikely to see him)
  • Jake the Mick (actually section hiking, probably too far ahead to catch up)
  • Grace Doolittle and Steph (only seen in registers fairly recently, maybe even after Bears Den actually, a good ways ahead)
  • Singer and Land Surfer (flip-floppers I met in New Hampshire, flopped to head south from Harpers Ferry to Springer a few days ago, can catch up if I make the effort)

I’ve seen the first five in registers for quite awhile, and my pace recently is definitely faster than theirs, so I’m sure I’ll see them at some point. Moose, Duckie, and Turbo are in striking distance, but their pace has always been faster than mine by maybe a mile or two a day or so. If I make a concerted effort I may catch up to them, but we’ll see what happens. (Given that I shelter-hop, this makes it harder to make up mileage because you get staggered so easily [when the choice is between 19 miles or 24 and it’s 18:00, and you’d been planning on the 24 to make the next day long as well, the easy choice snowballs into more than just five miles of difference pretty easily].) Singer and Land Surfer are well within catching distance; I don’t know their pace, so it’s hard to say when I’ll catch up. I very much doubt I’ll catch up to any of the others given their paces and how much time has passed from their register entries to my reading them. Still, we’ll see: now that I’m up to pace, I can have as much fun trying to catch up, perhaps failing, perhaps not, as I want, without any real physical pain. (It’s worth noting that on September 19, I was -222.4 miles from a 15-mile-a-day pace. A mere fifteen days later, I’m at -119.6 miles from pace [admittedly that did contain a 51-mile day, but even discounting that I’ve still made up four or five miles a day on average]. That mileage deficit I accumulated in the first 800 miles won’t be a problem.) It’s all mental from here on (not to say that it ever wasn’t just mental) depending on the goals I set and how hard I want to push myself.

08.12.09

An exercise in XPCOM programming, redux

The Exercise

Last time our hero was engaged in solving this posed streams problem:

Suppose you wish to complete one conceptually simple task in stream programming: copying a stream, i.e. reading all data from one stream and writing it all into another, where both streams are nonblocking. (Such a copier might buffer data read before it can be immediately written; assume this is a requirement for the purposes of this exercise.) Suppose for the moment that there is no readily available implementation of the nsIAsyncStreamCopier interface, so you have to roll your own stream copier. In what situation is it necessary to asynchronously wait with flags = WAIT_CLOSURE_ONLY to efficiently implement stream copying?

(Refer to the original post for full background if you’re not familiar with streams.)

The Answer

Copying from one nonblocking stream (the source) to another (the sink) involves waiting for the source to be able to provide data, reading in that data, waiting for the sink to be ready to accept data, and writing out buffered data. In the simple case there’s always data available to read and always space to write it. Let’s break down the cases where these aren’t the case:

There’s no data available to read from the source
Just wait for data to be available (assuming the sink hasn’t hit an error, if it has the copy’s done)
There’s no space in the sink to write data
There’s data available to write to the sink
Wait for that amount of data, or a fraction of it, to be writable
There’s no data available to write to the sink
???

What should happen in the final alternation? Suppose you waited for some amount of data to be writable, we’ll say 1 byte. What happens when the sink becomes that far unblocked? You’d have to be notified, and if there’s still no data to write you’re back where you started. Maybe you can bump up the amount you wait for, but how far should you bump? Increase arithmetically? Double? Any amount you bump to might result in more notifications when there’s nothing you can do.

There’s a further problem with waiting for some amount of data, one you’d only know if you were familiar with the async copying interfaces: the amount you specify when calling asyncWait to request notification when the stream’s unblocked again is only a hint. That is, the implementation is free to notify whenever it wants, so long as it’s not notifying when the state of the stream is unchanged from being previously blocked and unclosed. A stream might notify whenever any data is available, even if you bump up the amount. Therefore, if you just wait for an amount of data, and wait again if you have no data to write, you’ll be notified almost immediately (after any pending tasks in the thread event loop). Repeat this a few times and suddenly you’re spinning doing nothing, which is clearly inefficient. The main async stream classes in the tree ignore the requested count precisely as described here, so this isn’t simply an academic problem that we could ignore.

Here’s where you need WAIT_CLOSURE_ONLY. Until you have data to write, you don’t care about how much can be written to the sink. What you really care about is knowing if the sink closes (or gets in an error state), so you can stop copying immediately when that happens, rather than wait (perhaps indefinitely) until you have data to write and only determine when writing it that the sink’s closed (or in error). Using WAIT_CLOSURE_ONLY whenever you haven’t hit errors but don’t have any data to write neatly solves the problem of efficiently learning if the sink dies.

Older »