Loading...
Searching...
No Matches
thread.h
Go to the documentation of this file.
/* Simple Plugin API */
/* SPDX-FileCopyrightText: Copyright © 2021 Wim Taymans */
/* SPDX-License-Identifier: MIT */
#ifndef SPA_THREAD_H
#define SPA_THREAD_H
#include <string.h>
#include <errno.h>
#include <spa/utils/defs.h>
#include <spa/utils/hook.h>
#include <spa/utils/dict.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SPA_API_THREAD
#ifdef SPA_API_IMPL
#define SPA_API_THREAD SPA_API_IMPL
#else
#define SPA_API_THREAD static inline
#endif
#endif
#define SPA_TYPE_INFO_Thread SPA_TYPE_INFO_POINTER_BASE "Thread"
struct spa_thread;
#define SPA_TYPE_INTERFACE_ThreadUtils SPA_TYPE_INFO_INTERFACE_BASE "ThreadUtils"
#define SPA_VERSION_THREAD_UTILS 0
struct spa_thread_utils { struct spa_interface iface; };
struct spa_thread_utils_methods {
#define SPA_VERSION_THREAD_UTILS_METHODS 0
uint32_t version;
struct spa_thread * (*create) (void *object, const struct spa_dict *props,
void *(*start)(void*), void *arg);
int (*join)(void *object, struct spa_thread *thread, void **retval);
int (*get_rt_range) (void *object, const struct spa_dict *props, int *min, int *max);
int (*acquire_rt) (void *object, struct spa_thread *thread, int priority);
int (*drop_rt) (void *object, struct spa_thread *thread);
};
SPA_API_THREAD struct spa_thread *spa_thread_utils_create(struct spa_thread_utils *o,
const struct spa_dict *props, void *(*start_routine)(void*), void *arg)
{
return spa_api_method_r(struct spa_thread *, NULL,
spa_thread_utils, &o->iface, create, 0,
props, start_routine, arg);
}
SPA_API_THREAD int spa_thread_utils_join(struct spa_thread_utils *o,
struct spa_thread *thread, void **retval)
{
return spa_api_method_r(int, -ENOTSUP,
spa_thread_utils, &o->iface, join, 0,
thread, retval);
}
SPA_API_THREAD int spa_thread_utils_get_rt_range(struct spa_thread_utils *o,
const struct spa_dict *props, int *min, int *max)
{
return spa_api_method_r(int, -ENOTSUP,
spa_thread_utils, &o->iface, get_rt_range, 0,
props, min, max);
}
SPA_API_THREAD int spa_thread_utils_acquire_rt(struct spa_thread_utils *o,
struct spa_thread *thread, int priority)
{
return spa_api_method_r(int, -ENOTSUP,
spa_thread_utils, &o->iface, acquire_rt, 0,
thread, priority);
}
SPA_API_THREAD int spa_thread_utils_drop_rt(struct spa_thread_utils *o,
struct spa_thread *thread)
{
return spa_api_method_r(int, -ENOTSUP,
spa_thread_utils, &o->iface, drop_rt, 0, thread);
}
#define SPA_KEY_THREAD_NAME "thread.name" /* the thread name */
#define SPA_KEY_THREAD_STACK_SIZE "thread.stack-size" /* the stack size of the thread */
#define SPA_KEY_THREAD_AFFINITY "thread.affinity" /* array of CPUs for this thread */
#define SPA_KEY_THREAD_CREATOR "thread.creator" /* platform specific thread creator function */
#define SPA_KEY_THREAD_RESET_ON_FORK "thread.reset-on-fork" /* reset priority and policy for real-time threads
on fork. Default true */
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* SPA_THREAD_H */
defs.h
spa/utils/defs.h
spa_api_method_r
#define spa_api_method_r(rtype, def, type, o, method, version,...)
Definition hook.h:291
spa_thread_utils_drop_rt
SPA_API_THREAD int spa_thread_utils_drop_rt(struct spa_thread_utils *o, struct spa_thread *thread)
drop realtime priority
Definition thread.h:121
spa_thread_utils_acquire_rt
SPA_API_THREAD int spa_thread_utils_acquire_rt(struct spa_thread_utils *o, struct spa_thread *thread, int priority)
acquire realtime priority, a priority of -1 refers to the priority configured in the realtime module
Definition thread.h:111
spa_thread_utils_get_rt_range
SPA_API_THREAD int spa_thread_utils_get_rt_range(struct spa_thread_utils *o, const struct spa_dict *props, int *min, int *max)
get realtime priority range for threads created with props
Definition thread.h:101
spa_thread_utils_create
SPA_API_THREAD struct spa_thread * spa_thread_utils_create(struct spa_thread_utils *o, const struct spa_dict *props, void *(*start_routine)(void *), void *arg)
create a new thread that runs start with arg
Definition thread.h:81
spa_thread_utils_join
SPA_API_THREAD int spa_thread_utils_join(struct spa_thread_utils *o, struct spa_thread *thread, void **retval)
stop and join a thread
Definition thread.h:91
hook.h
spa/utils/hook.h
SPA_API_THREAD
#define SPA_API_THREAD
Definition thread.h:30
string.h
spa/utils/string.h
spa_dict
Definition dict.h:51
spa_interface
Definition hook.h:148
spa_thread_utils_methods
thread utils
Definition thread.h:58
spa_thread_utils_methods::drop_rt
int(* drop_rt)(void *object, struct spa_thread *thread)
drop realtime priority
Definition thread.h:76
spa_thread_utils_methods::version
uint32_t version
Definition thread.h:61
spa_thread_utils_methods::create
struct spa_thread *(* create)(void *object, const struct spa_dict *props, void *(*start)(void *), void *arg)
create a new thread that runs start with arg
Definition thread.h:64
spa_thread_utils_methods::get_rt_range
int(* get_rt_range)(void *object, const struct spa_dict *props, int *min, int *max)
get realtime priority range for threads created with props
Definition thread.h:70
spa_thread_utils_methods::join
int(* join)(void *object, struct spa_thread *thread, void **retval)
stop and join a thread
Definition thread.h:67
spa_thread_utils_methods::acquire_rt
int(* acquire_rt)(void *object, struct spa_thread *thread, int priority)
acquire realtime priority, a priority of -1 refers to the priority configured in the realtime module
Definition thread.h:74
spa_thread_utils
Definition thread.h:55
spa_thread_utils::iface
struct spa_interface iface
Definition thread.h:55
spa_thread
dict.h
spa/utils/dict.h