Re: Module: Threaded Sockets
I was checking your code and I have some doubts.
I didn't spent too much time but I can't find where ThreadMain is called from main module. If I understand correctly, you tried to do the same as on mysql module and other modules you can found. In that case you manage a list of sockets to be polled at each frame or whatever timeframe you want. I can't find that. Another question is if you have tried your calls to listent/recv/etc on udp sockets. They work slightly different and could broke how you check for incoming data. |
Re: Module: Threaded Sockets
Quote:
I don't know exactly how Sqlite threads work, but when i looked at them, they implemented SourceMod Threads, which are not that useful(too complex) in case of Sockets. As you can see, there are no Mutex's no Semaphores etc, etc in this module. I think my Model of implementation is itself synchronous. Quote:
Thanks for your time reviewing this shit :d |
Re: Module: Threaded Sockets
So you have a standalone thread looping for socket handling?
I'm not sure if calling forwards it's safe from another thread. I haven't checked but I guess isn't safe at least at pawn vm. 99% of tests could work, but you may hit some problem. |
Re: Module: Threaded Sockets
Quote:
Quote:
|
Re: Module: Threaded Sockets
Check yourself
https://wiki.alliedmods.net/Pawn_tutorial Quote:
What you can do is to have an ipc buffer to communicate between main thread and each child thread so you can keep your thread working like now but forwards should be called from main thread. |
Re: Module: Threaded Sockets
If we make such a buffer, when and how do we check for a change in such buffer in main thread ? Do note a point that we are talking about 1% of all cases.
|
Re: Module: Threaded Sockets
Quote:
Check dlls/mysqlx/threading.cpp on amxmodx source code. |
Re: Module: Threaded Sockets
Quote:
|
Re: Module: Threaded Sockets
You're doing modules, not plugins. On plugins it's expensive in time because stack and calls.
A lot of modules uses StartFrame, it not too expensive in this case. You have to do in game loop so it should be done in some game call. If you don't like to use directly StartFrame, do in 1/10 calls of it. Also you can create a dummy entity with custom Think time where you check for available data, but you will spent 1 entity from your limited max ent number... |
Re: Module: Threaded Sockets
Nice job. I was working on an update but this one is way better, so be sure to push it to amxmodx's github.
Feel free to take any code you want to improve your module, as I've seen that you didn't change much of the default code. https://github.com/Javivi/amxmodx/co...sockets-update Biggest changes are: Code:
- WinSock version changed from 1.1 to 2.2. |
All times are GMT -4. The time now is 20:26. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.