Thread: Design questions on prioriterized message handling

  1. #1
    Registered User
    Join Date
    Mar 2012
    Posts
    1

    Design questions on prioriterized message handling

    Hi, I would like to have some recommendation on my software design. I'm having a data structure fixed with 10 elements to store incoming messages. Whenever a massage is received, it would be stored into that data structure. The messages come with content and priority and subpriority levels

    Rules
    ------
    1) When the data structure is full (all 10 filled), the new message will overwrite the element in the data structure with lowest priority, and also with priority lower than the incoming message. If all elements are having higher priority, the message will be discarded.

    2) If the incoming massage having same priority with the lowest priority element in the data structure, subpriority will be compared and the (1) will be executed again.

    I'm thinking of creating a new priority queue array, storing indices and priority info to my data structure, with sorting algo to arrange the array according to priority. Whenever a new message arrives, it will look into the bottom of the arrays for comparison, then gradually move up the queue and repeat (1) & (2).

    I've got a feeling that this might not be an efficient implementation. I would be thankful if you could suggest a better way...

  2. #2
    Registered User javaeyes's Avatar
    Join Date
    Feb 2012
    Posts
    153
    With only 10 data members you're probably not going to gain much by writing an efficient sorting alg. Although you should probably check whether the newest message has a higher priority than the current highest, if so pop it onto first position, else check with the lowest and float upwards. I think. Also a massage is something you pay for and if you're lucky you leave feeling less horny than when you arrived.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem in message handling VC++
    By 02mca31 in forum Windows Programming
    Replies: 5
    Last Post: 01-16-2009, 09:22 PM
  2. some design questions
    By l2u in forum C++ Programming
    Replies: 19
    Last Post: 04-04-2008, 12:39 PM
  3. Design With Regards To A Splash Window - Custom Message?
    By Tonto in forum Windows Programming
    Replies: 2
    Last Post: 12-02-2006, 05:34 PM
  4. Message Handling
    By sethjackson in forum Windows Programming
    Replies: 14
    Last Post: 07-11-2006, 01:01 PM
  5. Control message handling
    By Homunculus in forum Windows Programming
    Replies: 5
    Last Post: 02-06-2006, 05:56 PM