How do you name MySQL threaded queries?
#1

title.
Reply
#2

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.
Reply
#3

Quote:
Originally Posted by Misiur
View Post
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
Reply
#4

Quote:
Originally Posted by Meller
View Post
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
as long as there are no inline called ThatInline inside a callback/function then your answer would be yes, also.

You don't need player parameter in that case, you could simply use playerid. Though your inline function should have a PROPER name that is related to it, its just a good practice.


so for example

pawn Code:
public OnPlayerConnect(playerid)
{

    inline ThatInline()
    {
        SendClientMessage(playerid, -1, "You have called ThatInline");
    }
    mysql_tquery_inline(
        sqlHandle,
        "SELECT COUNT(id) FROM accounts WHERE username = 'PatrickGTR'",
        using inline ThatInline
    );
    return 1;
}
Reply
#5

@PatrickGTR isn't it safer to pass parameters also? I don't know, maybe I'm paranoid!
Reply
#6

Quote:
Originally Posted by Y_Less
View Post
How do you mean "safer"? Why would you want two copies of a variable?
I'm just wondering if is there any case where the variable might change its value. Maybe after all it isn't needed at all due the closures thing.
Reply
#7

I don't use anymore mysql yinline since it makes crash my server.
Anyway, I put the prefix 'On' before the function's name.
Reply
#8

Quote:
Originally Posted by Y_Less
View Post
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.
Reply
#9

Quote:
Originally Posted by Meller
View Post
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
Reply
#10

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.
Reply
#11

@Meller, @Kaperstone: yes, that's what I was trying to say. Let's see if Y_Less clarifies this out.
Reply
#12

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)