Oct 29

The classic producer-consumer pattern makes a few assumptions in order to work. In this post I’ll discuss some of these assumptions, what happens when they break, and a cool solution to deal with it.
The two assumptions I’d like to discuss are:

  1. All producers are equal – this means that all producers are limited by one, shared limit – the mediator queue between them and the consumers. This is a great assumption for most implementations: usually you are limited by the amount of work your consumers can handle and usually those are limited by the amount of processors you would physically have, therefore it doesn’t matter if the piece of work came from producer X or producer Y – either way you’d still have the same amount of processors.
  2. Once sent to the queue, a producer doesn’t care about its products – this means that there is no link between the produced work and the producer once it has been sent to the mediation queue. And why should it? Its task was to create the work, afterwards its the consumer’s job to deal with the work, and then it would be the garbage collector’s task to reclaimed the memory space that work used. If the producer kept a link to the work, it couldn’t have been reclaimed without proper notifications between the producer and the consumer – and that would be completely against the decoupling nature of the producer-consumer pattern.

So far you might be thinking “these are good, based assumptions; why should they ever break?”. Well, keep on reading then. Continue reading »

Share
Jul 23

Working a bit with Objective-C recently in my spare time, I’ve noticed they introduced something to the Objective-C Protocol declaration, which is the ability to specify that certain methods in a protocol1 are optional for implementation. I could think of more than one occasion where I could have used it, and even on JDK interfaces that could have used it too. Continue reading »

Share
Feb 20

After some time the blog has failed to load for the most of you, I finally got to put it back together. Somehow the .htaccess files went all wrong… I suspect a certain WordPress plugin for damaging it so.

Sorry for the time-out, and hopefully now that I have some spare time (a few minutes a day) I could sit down and write one of those posts I recently wanted to publish here.

Side note: I removed the Google Friends Connect widget. It just didn’t work for me, I guess. If anyone here wants it back, the right place to ask for it is in the comments!

Share