MCPcopy Create free account
hub / github.com/GarageGames/Torque2D / run

Method run

engine/source/platform/platformNetAsync.cpp:108–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106}
107
108void NetAsync::run()
109{
110 if (isRunning())
111 return;
112
113 mRunning = true;
114 NameLookupRequest* lookupRequest = NULL;
115
116 while (isRunning())
117 {
118 lookupRequest = NULL;
119
120 // lock
121 lockNetAsyncMutex();
122 // if there is a request...
123 if (mLookupRequests.size() > 0)
124 {
125 // assign the first incomplete request
126 for (unsigned int i = 0; i < mLookupRequests.size(); ++i)
127 if (!mLookupRequests[i]->complete)
128 lookupRequest = mLookupRequests[i];
129 }
130
131 // unlock so that more requests can be added
132 unlockNetAsyncMutex();
133
134 // if we have a lookup request
135 if (lookupRequest != NULL)
136 {
137 NetAddress address;
138 Net::Error error = Net::stringToAddress(lookupRequest->remoteAddr, &address, true);
139 // do it
140 if (error != Net::NoError)
141 {
142 // oh well! leave the lookup data unmodified (h_length) should
143 // still be -1 from initialization
144 lookupRequest->complete = true;
145 }
146 else
147 {
148 // copy the stuff we need from the hostent
149 dMemset(lookupRequest->out_h_addr, 0,
150 sizeof(lookupRequest->out_h_addr));
151 dMemcpy(lookupRequest->out_h_addr, &address, sizeof(address));
152
153 lookupRequest->out_h_length = sizeof(address);
154 lookupRequest->complete = true;
155 }
156 }
157 else
158 {
159 // no lookup request. sleep for a bit
160 Platform::sleep(LOOKUP_REQUEST_CHECK_INTERVAL);
161 }
162 };
163}
164
165bool NetAsync::checkLookup(NetSocket socket, void* out_h_addr,

Callers 1

StartThreadFuncFunction · 0.45

Calls 5

lockNetAsyncMutexFunction · 0.85
unlockNetAsyncMutexFunction · 0.85
dMemsetFunction · 0.50
dMemcpyFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected