Anticipation

I’ve had this post kicking around in my drafts folder for a while now, and hey, it’s only been a year or two since my last post. My how time flies.

This is just a short bit of utility code I felt like sharing in case anyone else runs into the same problem I did.

The issue was with XmlWriter in the .NET Framework 2.0-3.5; I think the problem is still present in 4.0 and later but I don’t recall if I’ve tested this explicitly or not. One of the useful features of XmlWriter is that you can set the Indent property to true in order to make the resulting XML more human-readable instead of all smooshed together on one line.

Most of the time, this doesn’t cause any issues, because like HTML, whitespace is generally considered either insignificant or collapsible, so the extra spaces can be ignored. There is one exception to this rule, however: an element can have the xml:space="preserve" attribute applied to it, which means that all whitespace within that element is significant and must be preserved entirely intact (and thus must not be touched in any way by reformatting for humans).Continue reading Excessive whitespace in XmlWriter

Turn on a popular music station (something not dedicated to a specific theme, such as classic or concert music), and listen for 30-60 minutes. Count how many songs you hear that do not feature love, sex, or related topics (such as partying).

I’ve tried this a few times. So far my record high score is one point. And I’m not entirely sure I can count that one.

I’m not entirely sure what this says about the music or the audience or the people who decide what ends up on the radio. It just seemed like an interesting pattern.

Another game that looks impressive. And clearly I’m not the only one to think so — this fully funded within six hours, and hit US$1.5m in only nine.

And, not that it’ll make much difference since I don’t have that many readers, but: don’t forget Dreamfall, from my previous post. As this posts there’s less than 48 hours to go until the deadline. And while it’s already comfortably over the main goal, there’s some nice stretch goals up for grabs.

Dreamfall Chapters, the long-awaited sequel to Dreamfall and The Longest Journey, has finally opened its Kickstarter pledge drive.

It’s hard to express how much I love this series. But maybe some small indication is that I’ve been hanging around the (now going to be superseded) official forums for the games for so long that they made me a moderator.

As I post this (breaking my normal post time pattern), it’s still early days (only 8 hours in) and we’re still in the “initial surge” phase (these things tend to follow a double-humped pattern, with an initial surge, slow burn, and final push), so the pledge rate will start to drop off soon — but this looks like a solid beginning and very likely to achieve the funding goal.

So, last time I talked a bit about lock-free data structures. Here’s the second part, as promised.

I’m not going to go into great detail on the topic (unless people seem interested), and there’s plenty of other pages and sites dedicated to it. But I just wanted to share this little class I made. I doubt it’s original, but it is something I came up with on my own. (If that makes sense.)

This is a completely threadsafe and lock-free (though not atomic-free) way to pass an object from one thread to another. If you have many such objects, then a queue is typically the better way to go, but sometimes that’s a little too heavyweight for your needs. Essentially, this behaves like a queue or stack that can only hold a single object at a time — adding a second object will result in throwing away the first, but in a completely memory-safe manner. No memory will be leaked, no matter how many threads are adding or removing elements.Continue reading Multi-thread auto_ptr

As part of my day job, I’m always striving towards higher performance code while at the same time trying to retain a readable and flexible design (since customers are always changing what they want).

One of the big killers of performance is locks — they’re the most basic way to ensure mutual-exclusion of shared data between threads. Normally this is all well and good, and there are some situations in which locks are the only acceptable solution, but the big problem with them is that they block progress (which is part of their job, of course).Continue reading Lock Free

“Got” is a very strange word in the English language. Technically it’s the past tense of the verb “to get”. (And just to be difficult, so is “gotten” — at least in some dialects.) But that’s not the only way it’s used.

For example, the fragment “once you’ve got the window open” is fairly normal in common usage (though I’m fairly sure it’s frowned on in more formal grammar).

If you expand the contraction, “once you have got the window open” is still technically valid but is starting to sound quite dodgy — and it can be replaced by the equally-valid-but-still-dodgy “once you have the window open”, making the word “got” itself seemingly redundant. And yet “once you’ve the window open”, which logically ought to be the same, completely doesn’t work.

Of course the most correct (and formal) phrasing would have been “once you have opened the window”, which also works in the contracted form “once you’ve opened the window”. And yet it seems like most people seem to default to “you’ve got”, at least in casual conversation.

The original phrasing is using “to get” in its “achievement” sense — ie. “once you have achieved the state of the window being open”… not that anyone would normally state it in such a long-winded fashion. This is also why “have” works without it, as this is “to be” — ie. “once you have the window open” reads sufficiently close to the more formal phrasing above. It’s not as clear why it stops working once you reintroduce the contraction, though.

English is weird sometimes. Or maybe it’s just me.

(And yes, at times I’m a self-professed grammar/spelling nazi. Especially when it comes to misplaced apostrophes and homonyms (including using “of” instead of “have”). And even more especially when the person making the error should know better — eg. if formal writing is part of their job. (But clearly I have no objection to nested parentheses.))

I recently completed my first playthrough of Mass Effect 3, and I feel the urge to share some thoughts with the world. Not that anyone’s listening, of course.

I’ve previously played the earlier games, of course (all three on PC), although unlike many others so far I’ve only really done one complete playthrough of each. (I keep meaning to go back and try some different choices, but my pile of games I haven’t even played yet just keeps getting bigger…)

Note that (for reasons which will become apparent later) unlike my normal review style (where I try to avoid spoilers as much as possible), this one is going to be a bit spoileriffic. I will make a point of mentioning this again just before I get too blatant, though.