Code, rants and ramblings of a programmer.
Browse by Tags
Tagged Content List
A more usable API for a mutable thread safe collection
In my last post we discussed the problems with designing a safer API for mutable thread safe collections that employ only an internal locking system. The result was an API that was more difficult to mess up, yet pretty much unusable. Lets take a look at this problem and see if we can come up with a usable...
16 Feb 2009
Why are thread safe collections so hard?
Writing a collection which is mutable, thread safe and usable is an extremely difficult process. At least that’s what you’ve likely been told all through your schooling. But then you get out on the web and see a multitude of thread safe lists, maps and queues. If it’s so hard, why are there so many examples...
11 Feb 2009
Thread Local Storage template
Thread local storage is another method of synchronization between threads. It is different that most synchronization cases because instead of sharing state between threads it enables developers to have independent, thread specific pieces of data which have a similar or common purpose. The uses of thread...
21 Apr 2008
I've been busy lately and neglected my series on Active Objects . It's been a fairly busy time for me both in and out of work. Enough excuses, back to the fun. With the basic PipeSingleReader class, we now have the last piece necessary to create an ActiveObject. This article will focus...
30 Mar 2008
Previously we discussed a multi-thread safe queue like data structure using locks as an internal synchronization mechanism. This time we'll look at a version requiring no locks. In the previous version, locks were used to synchronize access to an underlying queue which stored the data. Removing the...
3 Mar 2008
Before we can get to building an Active Object implementation, there are some more primitive structures we need to define. Active Objects live on a separate thread where every call is executed in a serialized fashion on that thread. The next primitive will allow us to easily pass messages in the form...
2 Mar 2008
SynchronizationContext and Higher Order Functions
It's often useful to ensure that actions occur on specific threads, in particular event handlers. Take Windows Forms for instance where all operations on a Control must occur on the thread it was created on. Typically this is not a problem since WinForms respond to events such as Click, Move...
24 Feb 2008
Part of creating a multithreading program is understanding which threads objects live on. Seems simple enough and typically is. However it's nice to insert guarantees to match the design. One type of threading model is for objects or subsets of methods in an object to have an affinity to...
22 Feb 2008
Building a Future which returns no Value
In addition to Future<T> there is also the concept of Futures that don't return any values. Instead the perform the operation and return. Because there is no additional data to pass between the threads building an Empty Future is fairly straight forward. The biggest decision is how...
18 Feb 2008
The last post dealt with building the base Future class. Now we'll build the child class used to run Func<TResult> 's. The basic implementation is straight forward. The class will run a delegate typed to Func<TResult> in the override of RunCore. The trickiest part...
13 Feb 2008
Building the Base Future
In the end there are two basic types of Future implementations you can use. Futures which return no values Futures which return a value The rest of the behavior and shape of the Future is the same and screams for a pattern of sorts. I've found the best way to implement this behavior is through...
12 Feb 2008
If you read Jon Skeet's blog you'll notice he's been playing around lately with "push" style enumerators. Push enumerators are the concept of "we'll tell you when we're ready". This is different from IEnumerator<T> which is more of a pull; "ask me if I have more data model". His latest idea is...
5 Feb 2008
The first part of building a Future is ... Waiting
Future's are a great abstraction for asynchronous programming. One of the items making them so good is the easy manner in which you can declare one and wait for it to finish. The idea is to allow for many futures to be declared with as little overhead as possible. In order to do so you need to define...
4 Feb 2008
Active Objects and Futures
Herb Sutter gave one of my favorite and inspiring presentations. It is called "The Free Lunch is Over". The original article can be found here . My first encounter though came from his PDC presentation and highly recommend viewing that as well. The part that interested me...
28 Jan 2008
Tuples Part 7: Mutable Tuples
Part 6 left us with comparable tuples. At this point, the Tuple class is functionally complete. There will be a little more done with the debugability and overall fit into larger projects. But otherwise it is sound. Now the focus shifts to generating mutable tuples. Immutability...
23 Jan 2008
CLR Memory Model
Internally and externally I see a lot of questions about the .Net Memory Model. I think a lot of the confusion comes from the specs. Mainly that there are really two of them. The first is the ECMA CLI Memory Model (Partition 1, Section 12). This standard introduces a relaxed memory model which, IMHO...
17 Jan 2008
ISynchronizeInvoke ... now
ISynchronizeInvoke is an interface which allows you to execute a delegate synchronously or asynchronously. The implementer of the interface can control how the delegate is executed. In particular the implementer controls on which thread the delegate is executed. It's common for thread sensitive objects...
7 Jan 2008
Tuples Part 1
A tuple in computer science can be described as a set of name/value pairs. In some cases it can be described as simply a set of values that are accessible via an index . Previously I discussed how to create a Tuple inside of PowerShell . This series will focus on the use of Tuples in DotNet and how...
3 Jan 2008
Types of Immutability
By definition, an immutable object in computer science is one that is not able to change. Parallel coding is becoming more necessary as the number of cores in a processor are increasing but not the overall speed. As such immutability is will become more important because it is an important asset of multithreaded...
4 Dec 2007
Page 1 of 1 (19 items)
© 2014 Microsoft Corporation.
Privacy & Cookies