> I am not sure as the difference between readySessionBuffers and
> busySessionBuffers does not appear clearly to me (why is a
> BufferSession added
> to busySessionBuffers in fireEvent?)
>
> busySessionBuffers contains the SessionBuffers which have any events
> to fire in them.
I am sorry, but I don't get it. What do you exactly mean by "have any
events to fire in them"?
It means that all SessionBuffers in busySessionBuffers contains at least 1 events to fire. The SessionBuffer is added both to readySessionBuffers and to busySessionBuffers, but it is removed from readySessionBuffer soon by a worker thread (the leader).
In your case, you can simply retain what I've done with busySessionBuffers. You can safely modify fetchBuffer.
> readySessionBuffers contains the SessionBuffers which are waiting for
> the leader thread to process them. So a SessionBuffer is removed from
> readySessionBuffers when the leader thread takes it, but not from
> busySessionBuffers to prevent the same SessionBuffer from being added
> to readySessionBuffers and busySessionBuffers because it will cause
> severe synchronization issue.
But that is exactly what fireEvent does. It adds a same SessionBuffer to
the two sets. I am a bit confused.
They should contain the same stuff at the beginning, but busySessionBuffers are only used to prevent duplication because the SessionBuffer will get removed from readySessionBuffers.
HTH,
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
