coroutine/cotask: add cotask_get_name() API
This commit is contained in:
parent
a13e6ae7a3
commit
10ecc9ff42
4 changed files with 14 additions and 6 deletions
|
@ -17,6 +17,7 @@ void cosched_init(CoSched *sched) {
|
|||
CoTask *_cosched_new_task(CoSched *sched, CoTaskFunc func, void *arg, size_t arg_size, bool is_subtask, CoTaskDebugInfo debug) {
|
||||
assume(sched != NULL);
|
||||
CoTask *task = cotask_new_internal(cotask_entry);
|
||||
task->name = debug.label;
|
||||
|
||||
#ifdef CO_TASK_DEBUG
|
||||
snprintf(task->debug_label, sizeof(task->debug_label), "#%i <%p> %s (%s:%i:%s)", task->unique_id, (void*)task, debug.label, debug.debug_info.file, debug.debug_info.line, debug.debug_info.func);
|
||||
|
|
|
@ -759,3 +759,7 @@ void cotask_force_finish(CoTask *task) {
|
|||
|
||||
cotask_free(task);
|
||||
}
|
||||
|
||||
const char *cotask_get_name(CoTask *task) {
|
||||
return task->name;
|
||||
}
|
||||
|
|
|
@ -40,16 +40,17 @@ typedef struct CoWaitResult {
|
|||
CoEventStatus event_status;
|
||||
} CoWaitResult;
|
||||
|
||||
typedef struct CoTaskDebugInfo {
|
||||
const char *label;
|
||||
#ifdef CO_TASK_DEBUG
|
||||
typedef struct CoTaskDebugInfo {
|
||||
const char *label;
|
||||
DebugInfo debug_info;
|
||||
} CoTaskDebugInfo;
|
||||
DebugInfo debug_info;
|
||||
#endif
|
||||
} CoTaskDebugInfo;
|
||||
|
||||
#ifdef CO_TASK_DEBUG
|
||||
#define COTASK_DEBUG_INFO(label) ((CoTaskDebugInfo) { (label), _DEBUG_INFO_INITIALIZER_ })
|
||||
#else
|
||||
typedef char CoTaskDebugInfo;
|
||||
#define COTASK_DEBUG_INFO(label) (0)
|
||||
#define COTASK_DEBUG_INFO(label) ((CoTaskDebugInfo) { (label) })
|
||||
#endif
|
||||
|
||||
typedef struct CoSched CoSched;
|
||||
|
@ -72,6 +73,7 @@ void *cotask_malloc(CoTask *task, size_t size) attr_returns_allocated attr_mallo
|
|||
EntityInterface *cotask_host_entity(CoTask *task, size_t ent_size, EntityType ent_type) attr_nonnull_all attr_returns_allocated;
|
||||
void cotask_host_events(CoTask *task, uint num_events, CoEvent events[num_events]) attr_nonnull_all;
|
||||
CoSched *cotask_get_sched(CoTask *task);
|
||||
const char *cotask_get_name(CoTask *task) attr_nonnull(1);
|
||||
|
||||
BoxedTask cotask_box(CoTask *task);
|
||||
CoTask *cotask_unbox(BoxedTask box);
|
||||
|
|
|
@ -55,6 +55,7 @@ struct CoTask {
|
|||
CoTaskData *data;
|
||||
|
||||
uint32_t unique_id;
|
||||
const char *name;
|
||||
|
||||
#ifdef CO_TASK_DEBUG
|
||||
char debug_label[256];
|
||||
|
|
Loading…
Reference in a new issue