Posts: 578
Threads: 40
Joined: Dec 2016
Posts: 2,528
Threads: 124
Joined: Jul 2009
Reputation:
0
I use inline callbacks exclusively and call all my inlines "Handler". If you use public functions, then make sure their role is clear - as they are callbacks, usually use the "On" prefix, then exactly describe what they are processing.
Posts: 578
Threads: 40
Joined: Dec 2016
Quote:
Originally Posted by Misiur
I use inline callbacks exclusively and call all my inlines "Handler". If you use public functions, then make sure their role is clear - as they are callbacks, usually use the "On" prefix, then exactly describe what they are processing.
|
I just recently started using inline callbacks, can you confirm for me; I can name all the inlines: "ThatInline" and it will all work fine with no interceptions?
http://prntscr.com/hlqf74
Posts: 212
Threads: 14
Joined: Jul 2015
Reputation:
0
@PatrickGTR isn't it safer to pass parameters also? I don't know, maybe I'm paranoid!
Posts: 578
Threads: 40
Joined: Dec 2016
Quote:
Originally Posted by Y_Less
How do you mean "safer"? Why would you want two copies of a variable?
|
He probably means in these scenarios:
Client A connects to the server
Client A sends a server query to the active database handle
Client B connects to the server
Client B sends a server query to the active database handle
Client B receives the query response of Client A
Client A receives the query response of Client A
Now I don't know how inline work and neither does he probably, hence this question as this is remarkably done with normal callbacks using threaded queries.
Posts: 578
Threads: 40
Joined: Dec 2016
Quote:
Originally Posted by Meller
He probably means in these scenarios:
Client A connects to the server Client A sends a server query to the active database handle Client B connects to the server Client B sends a server query to the active database handle Client B receives the query response of Client A Client A receives the query response of Client A
Now I don't know how inline work and neither does he probably, hence this question as this is remarkably done with normal callbacks using threaded queries.
|
^ still a remaining question
Posts: 3,004
Threads: 12
Joined: May 2011
There is no "safer" in parameters.
You use them when you want to pass data from one event to another.
You can get scenario of Client B receiving event A and event B, and Client A receiving A and B.
This all depends upon your code.
The callback is just an event, the callback just fires, it has no target player or anything else.
You can use it however you wish, if you don't pass playerid, then you won't know who the query belongs to.
The extra parameters are just so you could continue the flow with your previous data.
Posts: 212
Threads: 14
Joined: Jul 2015
Reputation:
0
@Meller, @Kaperstone: yes, that's what I was trying to say. Let's see if Y_Less clarifies this out.
Posts: 15,941
Threads: 0
Joined: Jun 2008
OK, a clarification. When you call "Callback_Get" (which is called within the mysql_inline_query function (or whatever it is called - you know what I mean)), it stores the address of the function and all the local variables at the current time. When the callback is invoked, all the locals are restored. If you create two queries, two copies of the locals are stored. This copy of the locals is called a "closure".
The two are totally separate. You could make many queries in a loop, and when each one was called the loop variable would be whatever it was at query time. So 10 queries in a loop, 10 different future values of "i".
This is also why "Callback_Release" is required (but again, I think that is handled internally in the mysql include), to free up the memory used by the closure.