Version: Unity 6.1 Alpha (6000.1)
LanguageEnglish
  • C#

IJobForExtensions.RunByRef

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public static void RunByRef(ref T jobData, int arrayLength);

Parameters

jobData The job and data to execute.
arrayLength This job's Execute method will be called this many times, with its index argument ranging from 0 to (arrayLength - 1). Typically, this corresponds to the length of an array or array-like container passed in the job struct, but this is not necessarily the case.

Description

Performs the job's Execute method immediately on the same thread.

This variant passes the job struct by reference instead of by value, which can be faster than IJobForExtensions.Run for larger job structs. Note that worker threads always operate on a local copy of the job struct.

While this method is useful in development or test environments, it is typically a mistake to use it in production; it offers no real benefits over implementing the job code as a simple main-thread function call. To schedule a job to run asynchronously, use IJobForExtensions.ScheduleByRef.

Additional resources: IJobFor.