Posts: 7
Threads: 1
Joined: Aug 2009
Reputation:
0
Hi,
I'm wondering, how to make a callback. No, i don't want a fake callback called by a timer in a Pawn script, i mean a real callback, that my plugin calls in a Pawn script.
Thanks already.
Posts: 797
Threads: 21
Joined: Jan 2007
Reputation:
0
Go Download the source to the my Plugin, it has 2 callbacks which arent threaded or used much in ScriptPlayer.
Posts: 447
Threads: 6
Joined: May 2006
Reputation:
0
Those are not "fake" callbacks. Polling the plugin on a timer in PAWN is the safest way to execute any AMX functions from the main thread. If you put that code in a thread of your own, it will simply crash the server.
Posts: 89
Threads: 0
Joined: Jul 2009
Reputation:
0
No it works fine i just tested.
Posts: 447
Threads: 6
Joined: May 2006
Reputation:
0
It will not crash every time, of course, but since the threads are not synchronized, it will at random.
Posts: 7
Threads: 1
Joined: Aug 2009
Reputation:
0
Ok, so if i understand correctly, it will not crash as long as i don't use/modify global variables in the threaded function?
Posts: 447
Threads: 6
Joined: May 2006
Reputation:
0
No, only the AMX functions included in the SDK.
Posts: 447
Threads: 6
Joined: May 2006
Reputation:
0
In my tests, it is not processor-intensive as long as the polling function is light. Realistically, it is not the preferred option, but it is the only working method I have come across. Interesting that you mention message queues, but I do not see how they can be opened since PAWN is single-threaded (how can PAWN be informed of their creation?). They also seem to be limited as to what they can copy (e.g., only raw bytes and not objects). Do you think you could you expand on their implementation or perhaps give an example?
Posts: 447
Threads: 6
Joined: May 2006
Reputation:
0
Okay, the message queue is created in the main thread and messages are sent to it from another thread. Simple enough, but perhaps I am still misunderstanding something—how can these messages be received without blocking the main thread?
Posts: 447
Threads: 6
Joined: May 2006
Reputation:
0
If you could provide me with the value whenever you have access to your machine, it would be great.
Posts: 177
Threads: 4
Joined: Aug 2007
Reputation:
0
Once that is established a small SDK should be made to use callbacks the correct way, would be very usefull for future plugin development.