On 1/11/07, Joachim Draeger <[EMAIL PROTECTED]> wrote:
Am Donnerstag, den 11.01.2007, 18:55 +0000 schrieb robert burrell
donkin:
> > > > Think of a mbox and pop3. The backend opens the file and indexes it.
> > >
> > > that is not conversational state but an optimization
> >
> > Right, but without a session there is no possibility for that
> > optimization.
>
> there are different ways which this could be implemented. the current
> session concept is not necessary and in some cases can be detrimental.
>
> a flaw with the current API is that a session is opened before the
> factory has any idea about what's it's to be asked to do. it is
> therefore inefficient to perform any optimization when the session is
> opened.
>
> for example, whenever an IMAP session is opened the session
> pre-emptively caches the UIDs. at this time, the session cannot know
> whether a particular command will need this information or not.
As I said the last time: This is intended to be done on first use.
Just lazy initialization on demand. That way you need not know whether
it is needed or not.
this is a good example of why i claim that state needs to considered
more carefully. hopefully it may also illustrate why i claim that
session is harmful.
each time that getImapMailboxSession is called on MailboxManager, a
new instance is created and the cache is filled. the selected session
is cached in the ImapSessionState (the conversational session, i
think) so it's true that commands which operate on the selected
mailbox pay this cost only once.
any command which does not operate on the selected mailbox is forced
to the price for this setup on each execution.
this is a common defect found in this type of API: when the
ImapMailboxSession is obtained the backend has no way of knowing what
it will be used for. the backend can therefore not perform smart
optimizations.
there are alternative approaches to this kind of design but they
involve some up front payments in terms of increased analysis and (as
i've amply demonstrated) i don't know anyway near enough about IMAP to
perform this alone. interested?
- robert
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]