Googles appar
Huvudmeny

Post a Comment On: cbloom rants

"07-15-11 - Review of many Mutex implementations"

5 Comments -

1 – 5 of 5
Blogger Miroslav said...

I think its better to replace comments about sizes with STATIC_ASSERT's. So it will not compile if sizes are different. For example in Win x64 HANDLE==void*

July 16, 2011 at 4:34 AM

Blogger cbloom said...

Nah, I never use compile-time asserts. I'm really not a fan of self-checking code.

July 16, 2011 at 10:05 AM

Blogger cbloom said...

Ok, I apologize for the snarkiness, but I am like the *inventor* of using way too many compile-time asserts on everything (look at cblib/Threading.h for what my real code looks like).

Telling me to use more compile-time asserts is like telling Mister Rogers he needs to be nicer to people. Or telling the pope he should get a taller hat. Or telling Charlie Sheen he should really try this thing called cocaine. Or telling Brian Blessed he needs to speak up. Or...

July 16, 2011 at 10:28 AM

Blogger Miroslav said...

sorry, I was hoping that last part about HANDLE not being 32 bits on one of the popular OSes will make it less rude.
Quick look at Threading.h shows a lot of usual compiler-specific preprocessor plumbing. A dozen or so compile assertions are ok and dont stand out.

July 16, 2011 at 11:57 AM

Blogger cbloom said...

Yes, obviously if you actually wanted to use that type of lock on Win64, you would make "state" be a U64 and you would put the lock count in the top 8 bits or so, because handle values are always small on windows. (this is the same kind of thing that MS's primitives do internally).

July 16, 2011 at 12:27 PM

You can use some HTML tags, such as <b>, <i>, <a>

This blog does not allow anonymous comments.

Comment moderation has been enabled. All comments must be approved by the blog author.

You will be asked to sign in after submitting your comment.