zD12 / pircbotx

Automatically exported from code.google.com/p/pircbotx
0 stars 0 forks source link

Eliminate OutputThread #120

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Last issue of the night (hopefully): I want to remove OutputThread. It was 
originally there because PircBot was mostly single threaded, and blocking while 
waiting for a message to send was unacceptable.

Now though everything is highly multi-threaded and waiting isn't a problem. 
There are very few use cases where you want to say "send this eventually" and 
work on something else. It just doesn't make sense to complicate the design 
like that

I'm thinking of replacing PircBotX.sendRawLine with 
OutputThread.sendRawLineNow(), and deleting PircBotX.sendRawLineNow().

Advantages
 - All send* methods only have a single method to go to
 - One less mandatory thread
 - Significantly simpler PircBotXOutputTest
 - Exceptions in sending are reported immediately to the listener that send it, instead of being dumped to console
 - No more wondering if you message sent actually sent

Thoughts?

Original issue reported on code.google.com by Lord.Qua...@gmail.com on 1 Apr 2013 at 11:55

GoogleCodeExporter commented 9 years ago
I'm cool with this.

Original comment by entityreborn on 10 Apr 2013 at 6:40

GoogleCodeExporter commented 9 years ago
This turned out a little more complicated as I completely forgot about message 
delay when I came up with this idea. Since I didn't want to remove message 
delay but I still wanted an option to send a line now there is still 
sendRawLine and sendRawLineNow. However there's now also an option to reset the 
pending delay if you want, by default it doesn't since that's how PircBotX has 
always worked

I've replaced OutputThread with a Reentarant lock and a condition. Its a little 
more complicated but means that send blocks until its actually sent instead of 
being added to a queue and maybe sent.

I am going to need others to test to make sure it works like how they intend 
it, so I'm keeping this somewhat open

Original comment by Lord.Qua...@gmail.com on 14 Apr 2013 at 9:43

GoogleCodeExporter commented 9 years ago
Fixed with latest output commits

Original comment by Lord.Qua...@gmail.com on 31 Jul 2013 at 6:23