Results 1 to 3 of 3

Thread: Design problem/question

  1. #1
    Join Date
    Aug 2006
    Posts
    163
    Thanks
    12
    Thanked 5 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Design problem/question

    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.

  2. #2
    Join Date
    Aug 2006
    Posts
    163
    Thanks
    12
    Thanked 5 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Design problem/question

    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

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Design problem/question

    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.

Similar Threads

  1. Three Tier Database Programming - Design Pattern
    By sunil.thaha in forum Qt Programming
    Replies: 3
    Last Post: 8th July 2011, 04:00
  2. Design Patterns in Qt
    By bits in forum General Discussion
    Replies: 11
    Last Post: 11th May 2007, 09:13
  3. Dialog and code design issue
    By Gopala Krishna in forum Qt Programming
    Replies: 1
    Last Post: 24th September 2006, 17:54
  4. application design questions
    By nikita in forum Qt Programming
    Replies: 6
    Last Post: 28th August 2006, 00:35
  5. A Design Issue...
    By nupul in forum Qt Programming
    Replies: 6
    Last Post: 4th May 2006, 17:41

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.