Why List<T>.Foreach missed the boat AKA The great 'Personal threading maturity model' barrier

by alski 11. October 2007 22:21

With dotnet2.0 there a great set of functions added onto the generic list classes and their associates. I am particularly fond of anything which makes use of Predicate<T> like filter, but I've recently realised that this functionality is flawed.

The great 'Personal threading maturity model' barrier

How capable do you rate yourself with multi-threading? Fairly well, but that's a bit subjective isn't it. Have a quick look at the 'Personal threading maturity model', and hopefully you can give a more objective rating now. Until recently I was naive, probably a 2-3 on the Maturity model. I've used background workers to ease the UI and used lock based data structures to negotiate concurring problems.

Breaking the barrier

it may not be clear on today's hardware that further learning is necessary. Unfortunately, since manycore machines are not yet available

Larry O'Brien - January 2007

Well its now October 2007, and he was spot on. Personally I am starting to see my knowledge grow exponentially at the moment, and I can put it down to two factors.

  • Now I've replaced my old machine, I've become core aware. Multi-threading is now required to avoid the 50% flat out CPU graph.
  • At work, we are building a multi-processing system. Basically think of a big queue and a farm of application servers. Each application server picks up what it can handle according to current CPU/Memory constraints.

In both cases, the whole thing becomes a lesson in creating chunks of code that can be run in parallel. The easy bit is where we have piece of data and it goes through one path of logic. The challenge is where we have loops.

List<T>.Foreach

I now think that this functionality will NEVER be used. It will be consigned to the 'nice shame I doesn't respect manycore' bin. Instead people will be looking for MapReduce functionality, of which there are quite a few implementations already. Joel kicked off a rush of these implementations with his post Can Your Programming Language Do This?.

Instead we want List<T>.Map(Predicate<T> fn) and List<T>.Reduce(Predicate<T> fn) and the only problem is they don't exist yet.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

DotNet2.0

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

RecentComments

Comment RSS