[Opensim-dev] BlockingQueue

Dr Scofield DrScofield at xyzzyxyzzy.net
Wed Mar 26 14:52:40 UTC 2008


Stefan Andersson wrote:
>
> > > Preparing for the bug-a-thon friday, I want us to come together on 
> how
> > > we will write this out of the core; I think it will give us much
> > > better control over threading and deadlocking.
> > For people relatively new to the project, could you give any 
> examples of
> > particular problems here?
>
> Well, the thing with the BlockingQueue is that it functions this way:
>
> if something _Reads_ the queue, and it happens to be empty, the thread 
> is BLOCKED until something else _Adds_ to the queue. Of course, if 
> another thread comes along and reads from it, it is blocked as well, 
> and all of them are released in one merry explosion when an item is 
> Added. Which probably leads to all kinds of weird race conditions.
>
> In theory, this means that you can safely assume that there is 
> something on the queue on every read.
>
> In practice this leads to thread lock mayhem, since how the threads 
> interact with methods can be a bit tangly, to say the least, and that 
> the person that uses the blocking queue has to know EXACTLY what he's 
> doing. (And everybody that uses the code that uses the queue and so on.)
>
> All this just so that you could write
>
> while(true)
> {
>  Handle( m_blockingQueue.Read() ); // Or whatever the method name is
> }
>
> which in itself is just horrible, horrible, horrible.
switch to callbacks?

    cheers,
    dr scofield
>  


-- 
dr dirk husemann, mathmatics and computer science, ibm zurich research lab
SL: dr scofield ---- drscofield at xyzzyxyzzy.net ---- http://xyzzyxyzzy.net/
RL: hud at zurich.ibm.com - +41 44 724 8573 - http://www.zurich.ibm.com/~hud/




More information about the Opensim-dev mailing list