RE: Best and esiest to implemet pthread , GLib::Thread , GLib::Dispatcher




Thank you both

I have used
Libsoup :)

_______________________________________________________________________________________________________________________________
_____________________________________________________________________________________________________________________________________________

From
: jonathon quotidian org

Have you considered simply using libsoup instead of libcurl? Libsoup can do async I/O integrated with the glib mainloop so that you won't need to use threads (in theory).



From: Michael Moorman

Hi Kaiser,

This one way I would approach this problem.

1. Launch a GLib::Thread to download the files. The API is quite nice and easy to use.
2. Register a timeout function on the main gtk loop that periodically checks (maybe once every half second) on the status of the thread you launched in 1 ( see http://developer.gnome.org/gtkmm-tutorial/3.2/sec-timeouts.html.en ). This can safely update anything on the GUI since it's invoked from the main loop. Update any GUI related things (progress bar, error/success indications, etc) using this function.

Consider using a Glib::Mutex to facilitate safe communication between the two threads, i.e. synchronizing access to any shared buffer

Good luck!



Hello

I have made small gtkmm program that download some files from Internet by using libcurl..

But when the program start downloading the files it Freez until it finish (cuz of  single thread??)..

I knew that I must implement multi-threading to solve the problem ...

I have 3 classes in the program : WINDOW , APP , CURL

// here are some brief of the program
CURL contains CURLREAD function to download the files and some helper functions
APP contains other utils of program and contains getPKG() which get the URLS and download the files throught the object curl.curlread(url ,,,)
Window has progressBAR

CURL is object on APP ,,,, and APP is object on WINDOW

which one I should implement pthread ,  GLib::Thread  or GLib::Dispatcher ?!

_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]