Skip to content

Instantly share code, notes, and snippets.

@jacobsapps
Created August 15, 2025 09:26
Show Gist options
  • Save jacobsapps/325a23f4ac02f34c897a590b1dfe13fd to your computer and use it in GitHub Desktop.
Save jacobsapps/325a23f4ac02f34c897a590b1dfe13fd to your computer and use it in GitHub Desktop.
% if HAS_TASK_EXECUTOR:
/// - taskExecutor: The task executor that the child task should be started on and keep using.
/// Explicitly passing `nil` as the executor preference is equivalent to no preference,
/// and effectively means to inherit the outer context's executor preference.
/// You can also pass the ``globalConcurrentExecutor`` global executor explicitly.
% end
@discardableResult
public ${METHOD_VARIANT}( // Task ${METHOD_VARIANT}
${",\n ".join(adjust_params_for_kind(PARAMS))}
) ${ARROW_RETURN_TYPE}{
// Set up the job flags for a new task.
let flags = taskCreateFlags(
priority: priority,
isChildTask: false,
copyTaskLocals: ${'true' if not IS_DETACHED else 'false /* detached */'},
inheritContext: ${'true' if not IS_DETACHED else 'false /* detached */'},
enqueueJob: true,
addPendingGroupTaskUnconditionally: false,
isDiscardingTask: false,
isSynchronousStart: false)
% if HAS_ISOLATED_ANY:
let builtinSerialExecutor =
unsafe Builtin.extractFunctionIsolation(operation)?.unownedExecutor.executor
% end # HAS_ISOLATED_ANY
/* skipping some branches ... */
var task: Builtin.NativeObject?
task =
unsafe name.utf8CString.withUnsafeBufferPointer { nameBytes in
Builtin.createTask(
flags: flags,
% if HAS_ISOLATED_ANY:
initialSerialExecutor: builtinSerialExecutor,
% end
taskName: nameBytes.baseAddress!._rawValue,
operation: operation).0
}
#endif // $BuiltinCreateAsyncTaskName
% end # HAS_TASK_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment