Raised This Month: $ Target: $400
 0% 

[ANY] Brief Question


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 04-02-2012 , 17:08   [ANY] Brief Question
Reply With Quote #1

Consider the following pseudo-code:

Code:
global uninitialized A

if (CreateTimer(..., MyTimer, ...))
{
    Initialize A
}

MyTimer()
{
    Get A
}
Could I confirm, with a sufficiently small timer, that A can get accessed before it's initialized in the if-statement, and that I must choose a place like OnClientConnected to initialize the array instead (or simply initialize it from the start)?

Last edited by 11530; 04-02-2012 at 17:16.
11530 is offline
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 04-02-2012 , 17:43   Re: [ANY] Brief Question
Reply With Quote #2

Afaik the timer will be updated on the next frame.
But I'm not sure about that one.
Dr. Greg House is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 04-02-2012 , 17:55   Re: [ANY] Brief Question
Reply With Quote #3

The Source engine is single-threaded, so no.
__________________
asherkin is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 04-02-2012 , 20:36   Re: [ANY] Brief Question
Reply With Quote #4

I read somewhere that the engine uses a single thread for logical computations (and apparently another for networking) but edited mention of it from my OP in case I got burned for even mentioning it if it turned out to be a completely unrelated subjet. Almost didn't make the thread but wanted to confirm suspicions with good people like yourselves.

Good to know that I won't need another Initialize A in OnClientConnected() or something. Thanks you two for the quick replies!

Over and out.

Last edited by 11530; 04-02-2012 at 20:58.
11530 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:37.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode