Loom C API
Public Loom compiler C API
Toggle main menu visibility
Loading...
Searching...
No Matches
task.h
Go to the documentation of this file.
1
// Copyright 2026 The IREE Authors
2
//
3
// Licensed under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
7
#ifndef LOOMC_TASK_H_
8
#define LOOMC_TASK_H_
9
10
#include "
loomc/status.h
"
11
20
21
#ifdef __cplusplus
22
extern
"C"
{
23
#endif
24
31
typedef
struct
loomc_task_t
loomc_task_t
;
32
34
typedef
struct
loomc_task_vtable_t
{
44
void(
LOOMC_API_PTR
*
execute
)(
loomc_task_t
* task,
45
loomc_host_size_t
worker_ordinal);
46
48
void(
LOOMC_API_PTR
*
destroy
)(
loomc_task_t
* task);
49
}
loomc_task_vtable_t
;
50
51
struct
loomc_task_t
{
53
const
loomc_task_vtable_t
*
vtable
;
54
61
loomc_task_t
*
next
;
62
};
63
71
LOOMC_API_EXPORT
void
loomc_task_initialize
(
const
loomc_task_vtable_t
* vtable,
72
loomc_task_t
* out_task);
73
82
LOOMC_API_EXPORT
void
loomc_task_execute
(
loomc_task_t
* task,
83
loomc_host_size_t
worker_ordinal);
84
90
LOOMC_API_EXPORT
void
loomc_task_destroy
(
loomc_task_t
* task);
91
102
typedef
loomc_status_t
(
LOOMC_API_PTR
*
loomc_task_submit_fn_t
)(
103
void
* user_data,
loomc_task_t
* task);
104
106
typedef
struct
loomc_task_sink_t
{
108
loomc_task_submit_fn_t
submit
;
109
111
void
*
user_data
;
112
}
loomc_task_sink_t
;
113
123
LOOMC_API_EXPORT
loomc_status_t
loomc_task_sink_submit
(
loomc_task_sink_t
sink,
124
loomc_task_t
* task);
125
126
#ifdef __cplusplus
127
}
// extern "C"
128
#endif
129
130
#endif
// LOOMC_TASK_H_
LOOMC_API_EXPORT
#define LOOMC_API_EXPORT
Exports a public Loom C API symbol from a shared library build.
Definition
base.h:34
loomc_host_size_t
size_t loomc_host_size_t
Host allocation and container size type.
Definition
base.h:45
LOOMC_API_PTR
#define LOOMC_API_PTR
Marks a public callback function pointer type.
Definition
base.h:38
loomc_status_t
struct iree_status_handle_t * loomc_status_t
Opaque status handle.
Definition
base.h:55
status.h
Status codes and rich infrastructure error reporting.
loomc_task_sink_t
Borrowed destination for generic tasks.
Definition
task.h:106
loomc_task_sink_t::user_data
void * user_data
Opaque state passed to submit.
Definition
task.h:111
loomc_task_sink_t::submit
loomc_task_submit_fn_t submit
Callback accepting one task.
Definition
task.h:108
loomc_task_t
Base embedded at offset zero in one caller-defined work record.
Definition
task.h:51
loomc_task_t::vtable
const loomc_task_vtable_t * vtable
Static callbacks implementing the concrete task.
Definition
task.h:53
loomc_task_t::next
loomc_task_t * next
Sink-owned intrusive link while the accepted task is queued.
Definition
task.h:61
loomc_task_vtable_t
Stateless callbacks for one task representation.
Definition
task.h:34
loomc_task_vtable_t::destroy
void(* destroy)(loomc_task_t *task)
Destroys task storage after execution or rejected-submission cleanup.
Definition
task.h:48
loomc_task_vtable_t::execute
void(* execute)(loomc_task_t *task, loomc_host_size_t worker_ordinal)
Executes task exactly once without destroying its storage.
Definition
task.h:44
loomc_task_execute
void loomc_task_execute(loomc_task_t *task, loomc_host_size_t worker_ordinal)
Executes and then destroys an accepted task.
loomc_task_submit_fn_t
loomc_status_t(* loomc_task_submit_fn_t)(void *user_data, loomc_task_t *task)
Accepts ownership of one generic task.
Definition
task.h:102
loomc_task_destroy
void loomc_task_destroy(loomc_task_t *task)
Destroys a task without executing it.
loomc_task_sink_submit
loomc_status_t loomc_task_sink_submit(loomc_task_sink_t sink, loomc_task_t *task)
Submits a task and transfers ownership on success.
loomc_task_initialize
void loomc_task_initialize(const loomc_task_vtable_t *vtable, loomc_task_t *out_task)
Initializes a caller-allocated task base.
loomc
task.h
Generated by
1.17.0