Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ SetMinThreads()

bool System.Threading.PortableThreadPool.SetMinThreads ( int workerThreads,
int ioCompletionThreads )
inline

Definition at line 1384 of file PortableThreadPool.cs.

1385 {
1386 if (workerThreads < 0 || ioCompletionThreads < 0)
1387 {
1388 return false;
1389 }
1390 bool flag = false;
1391 bool flag2 = false;
1393 try
1394 {
1395 if (workerThreads > _maxThreads || !ThreadPool.CanSetMinIOCompletionThreads(ioCompletionThreads))
1396 {
1397 return false;
1398 }
1399 ThreadPool.SetMinIOCompletionThreads(ioCompletionThreads);
1400 if (ForcedMinWorkerThreads != 0)
1401 {
1402 return true;
1403 }
1404 short num = (_minThreads = (short)Math.Max(1, Math.Min(workerThreads, 32767)));
1405 if (_numBlockedThreads > 0)
1406 {
1407 if (_pendingBlockingAdjustment != PendingBlockingAdjustment.Immediately)
1408 {
1409 _pendingBlockingAdjustment = PendingBlockingAdjustment.Immediately;
1410 flag2 = true;
1411 }
1412 }
1413 else if (_separated.counts.NumThreadsGoal < num)
1414 {
1417 {
1418 flag = true;
1419 }
1420 }
1421 }
1422 finally
1423 {
1425 }
1426 if (flag)
1427 {
1428 WorkerThread.MaybeAddWorkingWorker(this);
1429 }
1430 else if (flag2)
1431 {
1432 GateThread.Wake(this);
1433 }
1434 return true;
1435 }
PendingBlockingAdjustment _pendingBlockingAdjustment

References System.Threading.PortableThreadPool._maxThreads, System.Threading.PortableThreadPool._minThreads, System.Threading.PortableThreadPool._numBlockedThreads, System.Threading.PortableThreadPool._pendingBlockingAdjustment, System.Threading.PortableThreadPool._separated, System.Threading.PortableThreadPool._threadAdjustmentLock, System.Threading.LowLevelLock.Acquire(), System.Threading.ThreadPool.CanSetMinIOCompletionThreads(), System.Threading.PortableThreadPool.CacheLineSeparated.counts, System.Threading.PortableThreadPool.ForcedMinWorkerThreads, System.Threading.PortableThreadPool.ThreadCounts.InterlockedSetNumThreadsGoal(), System.Math.Max(), System.Threading.PortableThreadPool.WorkerThread.MaybeAddWorkingWorker(), System.Math.Min(), System.Threading.PortableThreadPool.CacheLineSeparated.numRequestedWorkers, System.Threading.PortableThreadPool.ThreadCounts.NumThreadsGoal, System.Threading.LowLevelLock.Release(), System.Threading.ThreadPool.SetMinIOCompletionThreads(), and System.Threading.PortableThreadPool.GateThread.Wake().