hi;

On 27 August 2012 08:30, Frank Cox <thea...@melvilletheatre.com> wrote:
> On Mon, 27 Aug 2012 08:13:30 +0100
> Emmanuele Bassi wrote:
>
>> another thing is that if you feel you need to call sleep() anywhere in
>> a GUI then you are doing it wrong on an epic scale. the first rule of
>> mainloop-driven toolkits (such as GTK+) is: you do not block the main
>> loop. the second rule of mainloop-driven toolkits is: you do *not*
>> block the main loop. even if you're using sleep() to demonstrate the
>> fact that your long running operation is blocking the GUI, you're
>> doing it wrong.
>
> Okey dokey.  I'll study your message in more detail tomorrow since it's 
> getting
> pretty darn late here, but I do have one immediate question.
>
> My mailserver is small and I need to pace the email that I send to it to avoid
> DOS-ing it.  Therefore, I inject a pause of a fixed number of seconds between
> sending each outbound email.
>
> If I'm not allowed to pause the program, then how shall I create the delay
> between sending each message?

create a queue with all the messages, then use g_timeout_add_seconds()
to have a function called after a certain amount of seconds has
elapsed — and send a single mail from the head of the queue, after
which you update the queue. the timeout source function should return
TRUE if there are elements in the queue, and FALSE otherwise.

more information available here:

http://developer.gnome.org/glib/stable/glib-The-Main-Event-Loop.html
http://developer.gnome.org/glib/stable/glib-Double-ended-Queues.html

ciao,
 Emmanuele.

-- 
W: http://www.emmanuelebassi.name
B: http://blogs.gnome.org/ebassi/
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to