Multithreaded server
#1

Ok I have come across a solution to something that I have been wondering for a while now.

https://sampforum.blast.hk/showthread.php?tid=264178

How would I begin to use this?
For example I want to multithread a function that already exists.

I am going to store the active/inactive states for each thread and when I want to use a thread I will loop through to find one that is unused then use it?

Please give me an example of this being used.
Reply
#2

In Pawn..actually you dont need multi threads..

You just should write it better

Can you show us your function..or can you explain what you wanna do?
Reply
#3

There is no function I would like to multithread yet, everything runs smoothly. But in the future, I would like to multithread a path finding node system with npc police.
Reply
#4

This plugin is junk it won't work.
Reply
#5

PAWN is not made to be multithreaded, simply using that plugin will make sure your server will work worse than 1 thread as you will experience pretty much every bad thing, so just don't use it
even tho as long as your script is reasonably efficient (not talking about too much efficiency micro-management that some love to do, but just normal things) your server won't be using much of your CPU nor your RAM, and most of your CPU usage is gonna be your saving systems which MYSQL can be pqueried ...
Reply
#6

I do have a lot of saving on my server in the mysql database but it only saves every 30 minutes or when I shut down the server. Also it saves the players data when they disconnect.

When the server saves everything, everyone online will experience a brief moment of about 3 seconds of lag
Reply
#7

I experience 3 seconds of lag all the time when I get a blow job.
Reply
#8

[quote=jeffery30162;3588815]I do have a lot of saving on my server in the mysql database but it only saves every 30 minutes or when I shut down the server. Also it saves the players data when they disconnect.

I would try to delay the saving between each player, like 2 second for each player, this could probably prevent the server from "hanging"..

Example:
pawn Код:
new CurrentID;

//Every 30 minute
TrySavingAllWithoutLag()
{
    CurrentID = -1;
    TimerName();
}

Save(playerid) return 1;//Replace with your saving function.

forward TimerName();
public TimerName()
{
    if(++CurrentID == GetPlayerPoolSize()+1) return 1;

    if(IsPlayerConnected(CurrentID)) Save(CurrentID);
    SetTimer("TimerName", 2000, false);
    return 1;
}
//Note: It was never tested and not guaranteed to work, it's just an idea.
Also, You don't have to save everything every 30 minutes, try to decrease them and just save the important stuff, and try to get a database at the save host.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)