• Welcome to Valhalla Legends Archive.
 

Creating a Priority Queue Discussion

Started by Hazard, August 06, 2003, 02:04 PM

Previous topic - Next topic

What do you think of the idea outlined below? Do you like the idea?

Yay
11 (64.7%)
Nay
6 (35.3%)

Total Members Voted: 6

Hazard

Thanks to c0ol for this idea. It was discussed in an earlier post but I am interested in your opinions. Anyway here it is. The idea is to have two different queues. One queue is for normal commands (i.e. talk, kick, resign, unban, etc.) and the other for priority commands (i.e. ban [for ip banning purposes], deisgnate, and the like). I'll call the normal queue Alpha and the priority queue Beta.  A script would be written so that any command in the Alpha queue would be executed only after queue Beta is empty. What do you all think of this idea? Thanks

!~!HaZaRD!~!

"Courage is being scared to death - but saddling up anyway." --John Wayne

K

you really don't need two queues; you need one queue where items are inserted according to priority.  if you're using c++ have a look-see at the std::priority_queue template class.

Hazard

I know that you don't need two queues I was just wondering what people thought of the idea.

!~!HaZaRD!~!

"Courage is being scared to death - but saddling up anyway." --John Wayne

c0ol

Quote from: K on August 06, 2003, 02:17 PM
you really don't need two queues; you need one queue where items are inserted according to priority.  if you're using c++ have a look-see at the std::priority_queue template class.
uhh, ill disagree.  immagine this command:
.say hi\ban jim\say bye\say hi\ban sam\say hi\say bye\ban lamer
would ban jim sam and lamer first
then say hi bye hi hi bye

this is most easily done with 2 or more queues where the highest priority is checked first, if this queue contains any items they are processed. once the top queue is empty the second queue is checked, and so on untill  all queues are empty.

Skywing

Quote from: c0ol on August 06, 2003, 03:26 PM
Quote from: K on August 06, 2003, 02:17 PM
you really don't need two queues; you need one queue where items are inserted according to priority.  if you're using c++ have a look-see at the std::priority_queue template class.
uhh, ill disagree.  immagine this command:
.say hi\ban jim\say bye\say hi\ban sam\say hi\say bye\ban lamer
would ban jim sam and lamer first
then say hi bye hi hi bye

this is most easily done with 2 or more queues where the highest priority is checked first, if this queue contains any items they are processed. once the top queue is empty the second queue is checked, and so on untill  all queues are empty.
That is easily implemented with priority_queue.  I don't understand why you're wanting to use multiple queues.

UserLoser

Maybe he thought of the idea that I thought of...  Design a bot that loads two bots to the same channel, and both are designed to hold OPs.  Example: .ban * could clear 10 users in less than one second from the channel!  The bots would simply split up the queue.  And for things like .say Hello, it would send 'Hello' from the bot that hasn't sent a message in the longest time out of the two of them.

K

#6
Re: c0ol

Except with that method you're limited to two options: high priority :: low priority.  What if you want to have, say, database update commands performed after kicks / bans but before other output? Add another queue?  Not only does having only one (sorted) queue simplify coding and allow you to prioratize a new class of messages without touching your enqueuing / dequeuing routines, it will probably reduce memory usage.

Stealth

I've implemented this exact system by defining a Priority byte to piggyback each queue array member.


Public Type udtQueue
   Message As String
   Priority As Byte
End Type


Priority is specified when items are entered into the queue, and the queue is merely looped twice -- first to check for highest-priority messages, if one is found it's sent; if no highest-priority items are found the oldest entry in the queue is delivered to battle.net and the rest are shifted down.
- Stealth
Author of StealthBot

Skywing

Quote from: UserLoser on August 06, 2003, 03:37 PM
Maybe he thought of the idea that I thought of...  Design a bot that loads two bots to the same channel, and both are designed to hold OPs.  Example: .ban * could clear 10 users in less than one second from the channel!  The bots would simply split up the queue.  And for things like .say Hello, it would send 'Hello' from the bot that hasn't sent a message in the longest time out of the two of them.
His explanation of why he was using multiple queues pretty much rules that out.  Besides, you'd still be wanting a priority_queue for each BNCS connection, anyway.

Banana fanna fo fanna

Could have your send() method take an optional parameter which is whether this message is high priority. If so, all the high priority messages go out first, then the rest of the standard priority messages.

Adron

Nice idea, but make more than two different priorities. Like, a specific ban of a username should probably have a higher priority than a wildcard .ban *, single line responses higher priority than long responses etc.

Mesiah / haiseM

I agree with not having 2 seperate queue's, why do that, when you could easily design the queue with more parameters and other options to split them up before sending. Not only would that be better, but with 2 queue's, your more likely to flood a little easier than using just one.
]HighBrow Innovations
Coming soon...

AIM Online Status: 

tA-Kane

Quote from: MesiaH on August 06, 2003, 07:40 PMNot only would that be better, but with 2 queue's, your more likely to flood a little easier than using just one.
Not if you don't write it sloppily.
Macintosh programmer and enthusiast.
Battle.net Bot Programming: http://www.bash.org/?240059
I can write programs. Can you right them?

http://www.clan-mac.com
http://www.eve-online.com

Camel

           With ExecSQL("SELECT TOP 1 id, text " & _
                        "FROM buffer " & _
                        "ORDER BY priority DESC, " & _
                                 "id ASC" & _
                        ";")

FuZe

If you empty out the priority queue completely, before sending any of the normal queue, hmm, in some cases that might slow down response times a lot.  Maybe you mite consider sending three priority queue messages for every 1 normal queue or something similar to that.