View Full Version : Design problem/question

26th September 2006, 18:16
This is more of a general design problem than anything.

I am making a binary newsgroup reader. I'm quite far along, thanks to this forum, but I am at a bit of a quandary with regards to the design of the program.

The program has different servers that one can enter to download from, and each server has a certain amount of connections that it can connect with. The problem I'm facing is that when you log onto a server and navigate, you will que files for downloading. Then the program should download the files you queue.
I'm not sure of the best way to keep track of this. Right now I am running the connection threads in their own threads in blocking mode. I feel that this is the right way to do this. What I'm not so sure about is how the program should communicate with the threads, how it should tell them that they are needed to download something. At the moment for each server that you conenct to, I make a QList which stores the server info, and underneath each server object in the QList the connection threads. I'm not sure that this is an elegant way to do it or not. Neither am I sure as to wether I should have the connection threads query a download queue (and if so, I'm not sure as to how I should best accomplish this) or weather I should make the server notify the threads that they should wakeup, connect and download something.

I thought I would ask here before trying one or the other, as maybe more experianced programmers here would know of a more or less standard way of doing this sort of thing, as it would seem to me to be a problem that one would face quite often with this sort of client/server relation.

27th September 2006, 22:10
Basically what I'm asking is should the connection threads check the queue every so often (i.e. make a timer and every 1000 milliseconds have the threads check the queue) or should the program notify the threads that new data is available to be downloaded or is there another way that something like this should be done? It's a bit hard to search for something like this on Google :p

27th September 2006, 22:45
You can use QSemaphore to stop your thread when there are no files to download left and QMutex to guard the list of files to download.