This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

modules and multi-threading

Discussion of Eggdrop's code and module programming in C.
K
Kappa007
Voice
Posts: 38
Joined: Tue Jul 26, 2005 9:53 pm

Post by Kappa007 »

Actually that's the purpose i'm using it already for.
Using MySQL++ in a separate thread...
h
heretic^
Voice
Posts: 5
Joined: Tue Mar 23, 2004 4:09 pm
Contact:

Post by heretic^ »

Yes, i've done this before. I made a thread-safe wrapper for eggdrop's i/o functionality, and yes I did have a valid use for threads as well. It all works great.
In the midst of life, we are in death
K
Kappa007
Voice
Posts: 38
Joined: Tue Jul 26, 2005 9:53 pm

Post by Kappa007 »

See, i'm not the only one :D

Nevertheless, I think I might change to the "use-tcl-sockets-for-IPC" approach De Kus mentioned.
Just "feels" better than polling some queue once a second.
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

so where is your working, fully functional stuff? (addressing both kappa & heretic)

if it's supposed to serve the general public, please provide a download link to it

if it's private, I see no point of discussing it here
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

Kappa007 wrote:I think I might change to the "use-tcl-sockets-for-IPC" approach De Kus mentioned.
Just "feels" better than polling some queue once a second.
actually its polled about once every half second. when I used fileevent with millisecond timestamps I noticed they are always in 500ms steps. But usually it doesnt matter if your bot response in 100ms or 500ms, since the user on IRC will both see due to server queue usually at the same time.

A valid use of thread safe eggdrop would be, if you cannot fork into a child process for some reason (like sharing larger amount of data for fast acccess in both ways). But for that purpose you could still hack into the eggdrop mainloop to exchange data with the child without touching offer parts of the bot.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
h
heretic^
Voice
Posts: 5
Joined: Tue Mar 23, 2004 4:09 pm
Contact:

Post by heretic^ »

demond wrote:so where is your working, fully functional stuff? (addressing both kappa & heretic)

if it's supposed to serve the general public, please provide a download link to it

if it's private, I see no point of discussing it here
http://www.scorebots.org

I cant really release the source code, but i'm more than willing to supply help to anyone that needs it.

I basically created a cmodule to run multiple "scorebots" per single eggdrop. The reason why I needed to use threads instead of some "polling" system was to create real time output in relation to the "scorebot". Right now I run a free IRC service to the users of the GameSurge network. Currently we are serving over 500 channels.
In the midst of life, we are in death
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

so basicly every single scorebot is single threaded again?! Thats no multithreading like demond wanted it to hear :D. The problems that occur with multithreading is only meaningfull, when there is more than one thread for the same bot/IRC connection.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
h
heretic^
Voice
Posts: 5
Joined: Tue Mar 23, 2004 4:09 pm
Contact:

Post by heretic^ »

yes, multi-threaded in the fact that if channel #a has ScoreBot-01 and channel #b has ScoreBot-01 and they're both running a scorebot at the same time, then there are 2 threads running the scorebot code.

each thread has to allocate at least 1 UDP socket, and sometimes 1 TCP socket to connect to and interact with the desired gameserver, then it parses the gamelogs updates a few player nodes, and outputs through a thread-safe function
In the midst of life, we are in death
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

heretic^ wrote:
demond wrote:so where is your working, fully functional stuff? (addressing both kappa & heretic)

if it's supposed to serve the general public, please provide a download link to it

if it's private, I see no point of discussing it here
http://www.scorebots.org
nothing to download there, so it's basically irrelevant to this forum's purpose (at least as I understand it - it's not about MT in general and even not about the programming in general, but about eggdrop and eggdrop modules programming - and eggdrop is open-source)
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
h
heretic^
Voice
Posts: 5
Joined: Tue Mar 23, 2004 4:09 pm
Contact:

Post by heretic^ »

Kappa007 wrote:Anyone seen/used any other approach?
demond wrote:nothing to download there, so it's basically irrelevant to this forum's purpose (at least as I understand it - it's not about MT in general and even not about the programming in general, but about eggdrop and eggdrop modules programming - and eggdrop is open-source)
I'm sorry if you feel that's irrelevant but I was merely responding to Kappa's post, I apologize if I offended you in the process of contributing to this thread. I'm not trying to start a flamewar here or anything I was just merely responding to the author of this thread.
In the midst of life, we are in death
K
Kappa007
Voice
Posts: 38
Joined: Tue Jul 26, 2005 9:53 pm

Post by Kappa007 »

No hurry, i'll put my stuff under public domain once i got time to cleanup the code...
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

heretic^ wrote:
Kappa007 wrote:Anyone seen/used any other approach?
demond wrote:nothing to download there, so it's basically irrelevant to this forum's purpose (at least as I understand it - it's not about MT in general and even not about the programming in general, but about eggdrop and eggdrop modules programming - and eggdrop is open-source)
I'm sorry if you feel that's irrelevant but I was merely responding to Kappa's post, I apologize if I offended you in the process of contributing to this thread. I'm not trying to start a flamewar here or anything I was just merely responding to the author of this thread.
no offense taken, you've done a good job; hopefully you'll share it some day with the community
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
Post Reply