Threads being used by Tinymail
About
This document assumes that you are using libtinymail-camel and documents the usage of threads. When Tinymail is absolutely doing nothing, it'll have one or two threads. The mainloop and the thread used for monitoring the online state (depending on the TnyDevice's implementation). When it's working hard on one account, it'll have two or three threads. When multiple accounts are working hard, it'll have an extra thread for each account. When you are sending messages, it can temporarily create up to two extra threads. Sometimes three extra ones. If your application creates its own threads, those are of course also added to the count.
Signals
Signals and observer update notifies have their own page here.
TnyCamelStoreAccount
Queue thread per store account
Each store account has a queue. If items are on the queue, a thread will be running to one by one handle them. If no items are on the queue, no thread will run. Only asynchronous methods of a store account (or a folder) are queued on this queue. Non asynchronous methods are launched in the thread where the method was launched (this might change in future).
Connecting
Connecting is described on this page.
Operations
Operations are described on this page.
In case of IMAP, the idle thread
Once connected and a tny_folder_refresh or tny_folder_refresh_async happened will libtinymail-camel, in case of an IMAP account that supports IDLE, start a thread that monitors the socket for IDLE events. This thread will process received events and will periodically stop and restart the IDLE state. For example the "folder_changed" signal handler of priv->folder of TnyCamelFolder (usually) happens in this thread.
TnyCamelSendQueue
A TnySendQueue is what implements being asynchronous for a TnyTransportAccount. For libtinymail-camel's TnyCamelTransportAccount a TnyCamelSendQueue has been put in place. This impementation of TnySendQueue has for its sentbox and outbox TnyFolder properties two local Maildirs. There are three threads involved: two store-account's queues and one "sending" queue thread.
Queue thread per sendqueue
One queue thread is used for actually sending the messages. This thread grabs a message from the outbox, transfers it using the TnyTransportAccount and moves it to the sentbox.
Queue thread for the outbox and the sentbox of the sendqueue
In TnyCamelTransportAccount each folder (outbox and sentbox) has its own embedded (virtual) store account. You don't notice its existence but they are indeed created internally. Each such store account has a queue (with corresponding thread). It's only used when a message is being added, though.
TnyDevice
Often the implementation of TnyDevice uses a thread to monitor the online status. The application developer can either reuse one of the existing TnyDevice implementations (like the one for Conic or Network Manager) or implement its own. Very often such implementations use a thread.
The GMainLoop
Usually do ui applications run in a mainloop. In case of Gtk+ applications (or Hildon) this is a GMainLoop that gets started when you launched gtk_main.
