Due to naively designing the internal organs of Tinymail’s async methods, I introduced a lot of threading and locking difficulties to the application developer who’s building an application on top of Tinymail.
We noticed this and therefore we did something about it (we is Rob Taylor and me). The solution was to introduce an internal queue that guarantees locking order for operations and during the connecting of accounts. The callback, which the application developer can implement, will make such a queue item waits for its completion. They happen in the mainloop, so that is done using a small little “GCond” construction. Dialogs like the password dialog, the SSL question and the code that gets launched in case the password was wrong will now all happen in the mainloop of the application. This makes it much more easy for the application developer to implement them using user interface components like the GNOME password manager’s dialogs.
This work was being done in this branch of Tinymail and will, with the migration of an E-mail client that is being build on top of Tinymail, be merged back to Tinymail’s trunk starting tomorrow. Some of the work has already been merged in trunk. Mostly work that was not related to the account connecting and initialization (which includes the password -and the SSL question things).
Hereby apologies for making these horrible internal design decisions. I guess I focused at the start of the project too much on the external design. I guess I hoped too much that internal organs would automatically become good too. This kludge made the external API behave difficult for application developers. It’s fixed now, and we wont make the same mistakes again. I believe this work is one of the key pieces in the puzzle that can turn Tinymail from a hobby project into an actual product.
The good thing about the kludge is that it forced me to make a lot of the locking both very fine grained and yet very correct. With the locking order in place now, this should mean that the overall quality should have improved a lot. We’ll see. Let the testers begin!
Another key piece in the puzzle is to someday have a libtinymail-dbus. We’re already planning and designing this, indeed.