thread.h File Reference

Thread. More...

Data Structures

struct  spdk_io_channel
 Represents a per-thread channel for accessing an I/O device. More...
 
struct  spdk_thread_stats
 

Macros

#define SPDK_POLLER_REGISTER(fn, arg, period_microseconds)   spdk_poller_register_named(fn, arg, period_microseconds, #fn)
 

Typedefs

typedef int(* spdk_new_thread_fn) (struct spdk_thread *thread)
 A function that is called each time a new thread is created. More...
 
typedef int(* spdk_thread_op_fn) (struct spdk_thread *thread, enum spdk_thread_op op)
 Function to be called for SPDK thread operation.
 
typedef bool(* spdk_thread_op_supported_fn) (enum spdk_thread_op op)
 Function to check whether the SPDK thread operation is supported.
 
typedef void(* spdk_msg_fn) (void *ctx)
 A function that will be called on the target thread. More...
 
typedef void(* spdk_thread_pass_msg) (spdk_msg_fn fn, void *ctx, void *thread_ctx)
 Function to be called to pass a message to a thread. More...
 
typedef int(* spdk_poller_fn) (void *ctx)
 Callback function for a poller. More...
 
typedef struct spdk_poller *(* spdk_start_poller) (void *thread_ctx, spdk_poller_fn fn, void *arg, uint64_t period_microseconds)
 Function to be called to start a poller for the thread. More...
 
typedef void(* spdk_stop_poller) (struct spdk_poller *poller, void *thread_ctx)
 Function to be called to stop a poller. More...
 
typedef int(* spdk_io_channel_create_cb) (void *io_device, void *ctx_buf)
 I/O channel creation callback. More...
 
typedef void(* spdk_io_channel_destroy_cb) (void *io_device, void *ctx_buf)
 I/O channel destruction callback. More...
 
typedef void(* spdk_io_device_unregister_cb) (void *io_device)
 I/O device unregister callback. More...
 
typedef void(* spdk_channel_msg) (struct spdk_io_channel_iter *i)
 Called on the appropriate thread for each channel associated with io_device. More...
 
typedef void(* spdk_channel_for_each_cpl) (struct spdk_io_channel_iter *i, int status)
 spdk_for_each_channel() callback. More...
 

Enumerations

enum  spdk_thread_op { SPDK_THREAD_OP_NEW, SPDK_THREAD_OP_RESCHED }
 SPDK thread operation type.
 

Functions

int spdk_thread_lib_init (spdk_new_thread_fn new_thread_fn, size_t ctx_sz)
 Initialize the threading library. More...
 
int spdk_thread_lib_init_ext (spdk_thread_op_fn thread_op_fn, spdk_thread_op_supported_fn thread_op_supported_fn, size_t ctx_sz)
 Initialize the threading library. More...
 
void spdk_thread_lib_fini (void)
 Release all resources associated with this library.
 
struct spdk_thread * spdk_thread_create (const char *name, struct spdk_cpuset *cpumask)
 Creates a new SPDK thread object. More...
 
void spdk_set_thread (struct spdk_thread *thread)
 Force the current system thread to act as if executing the given SPDK thread. More...
 
int spdk_thread_exit (struct spdk_thread *thread)
 Mark the thread as exited, failing all future spdk_thread_send_msg(), spdk_poller_register(), and spdk_get_io_channel() calls. More...
 
bool spdk_thread_is_exited (struct spdk_thread *thread)
 Returns whether the thread is marked as exited. More...
 
void spdk_thread_destroy (struct spdk_thread *thread)
 Destroy a thread, releasing all of its resources. More...
 
void * spdk_thread_get_ctx (struct spdk_thread *thread)
 Return a pointer to this thread's context. More...
 
struct spdk_cpusetspdk_thread_get_cpumask (struct spdk_thread *thread)
 Get the thread's cpumask. More...
 
int spdk_thread_set_cpumask (struct spdk_cpuset *cpumask)
 Set the current thread's cpumask to the specified value. More...
 
struct spdk_thread * spdk_thread_get_from_ctx (void *ctx)
 Return the thread object associated with the context handle previously obtained by calling spdk_thread_get_ctx(). More...
 
int spdk_thread_poll (struct spdk_thread *thread, uint32_t max_msgs, uint64_t now)
 Perform one iteration worth of processing on the thread. More...
 
uint64_t spdk_thread_next_poller_expiration (struct spdk_thread *thread)
 Return the number of ticks until the next timed poller would expire. More...
 
int spdk_thread_has_active_pollers (struct spdk_thread *thread)
 Returns whether there are any active pollers (pollers for which period_microseconds equals 0) registered to be run on the thread. More...
 
bool spdk_thread_has_pollers (struct spdk_thread *thread)
 Returns whether there are any pollers registered to be run on the thread. More...
 
bool spdk_thread_is_idle (struct spdk_thread *thread)
 Returns whether there are scheduled operations to be run on the thread. More...
 
uint32_t spdk_thread_get_count (void)
 Get count of allocated threads.
 
struct spdk_thread * spdk_get_thread (void)
 Get a handle to the current thread. More...
 
const char * spdk_thread_get_name (const struct spdk_thread *thread)
 Get a thread's name. More...
 
uint64_t spdk_thread_get_id (const struct spdk_thread *thread)
 Get a thread's ID. More...
 
struct spdk_thread * spdk_thread_get_by_id (uint64_t id)
 Get the thread by the ID. More...
 
int spdk_thread_get_stats (struct spdk_thread_stats *stats)
 Get statistics about the current thread. More...
 
uint64_t spdk_thread_get_last_tsc (struct spdk_thread *thread)
 Return the TSC value from the end of the last time this thread was polled. More...
 
int spdk_thread_send_msg (const struct spdk_thread *thread, spdk_msg_fn fn, void *ctx)
 Send a message to the given thread. More...
 
int spdk_thread_send_critical_msg (struct spdk_thread *thread, spdk_msg_fn fn)
 Send a message to the given thread. More...
 
void spdk_for_each_thread (spdk_msg_fn fn, void *ctx, spdk_msg_fn cpl)
 Send a message to each thread, serially. More...
 
struct spdk_poller * spdk_poller_register (spdk_poller_fn fn, void *arg, uint64_t period_microseconds)
 Register a poller on the current thread. More...
 
struct spdk_poller * spdk_poller_register_named (spdk_poller_fn fn, void *arg, uint64_t period_microseconds, const char *name)
 Register a poller on the current thread with arbitrary name. More...
 
void spdk_poller_unregister (struct spdk_poller **ppoller)
 Unregister a poller on the current thread. More...
 
void spdk_poller_pause (struct spdk_poller *poller)
 Pause a poller on the current thread. More...
 
void spdk_poller_resume (struct spdk_poller *poller)
 Resume a poller on the current thread. More...
 
void spdk_io_device_register (void *io_device, spdk_io_channel_create_cb create_cb, spdk_io_channel_destroy_cb destroy_cb, uint32_t ctx_size, const char *name)
 Register the opaque io_device context as an I/O device. More...
 
void spdk_io_device_unregister (void *io_device, spdk_io_device_unregister_cb unregister_cb)
 Unregister the opaque io_device context as an I/O device. More...
 
struct spdk_io_channelspdk_get_io_channel (void *io_device)
 Get an I/O channel for the specified io_device to be used by the calling thread. More...
 
void spdk_put_io_channel (struct spdk_io_channel *ch)
 Release a reference to an I/O channel. More...
 
static void * spdk_io_channel_get_ctx (struct spdk_io_channel *ch)
 Get the context buffer associated with an I/O channel. More...
 
struct spdk_io_channelspdk_io_channel_from_ctx (void *ctx)
 Get I/O channel from the context buffer. More...
 
struct spdk_thread * spdk_io_channel_get_thread (struct spdk_io_channel *ch)
 Get the thread associated with an I/O channel. More...
 
void spdk_for_each_channel (void *io_device, spdk_channel_msg fn, void *ctx, spdk_channel_for_each_cpl cpl)
 Call 'fn' on each channel associated with io_device. More...
 
void * spdk_io_channel_iter_get_io_device (struct spdk_io_channel_iter *i)
 Get io_device from the I/O channel iterator. More...
 
struct spdk_io_channelspdk_io_channel_iter_get_channel (struct spdk_io_channel_iter *i)
 Get I/O channel from the I/O channel iterator. More...
 
void * spdk_io_channel_iter_get_ctx (struct spdk_io_channel_iter *i)
 Get context buffer from the I/O channel iterator. More...
 
void spdk_for_each_channel_continue (struct spdk_io_channel_iter *i, int status)
 Helper function to iterate all channels for spdk_for_each_channel(). More...
 

Detailed Description

Thread.

Typedef Documentation

◆ spdk_channel_for_each_cpl

typedef void(* spdk_channel_for_each_cpl) (struct spdk_io_channel_iter *i, int status)

spdk_for_each_channel() callback.

Parameters
iI/O channel iterator.
status0 if it completed successfully, or negative errno if it failed.

◆ spdk_channel_msg

typedef void(* spdk_channel_msg) (struct spdk_io_channel_iter *i)

Called on the appropriate thread for each channel associated with io_device.

Parameters
iI/O channel iterator.

◆ spdk_io_channel_create_cb

typedef int(* spdk_io_channel_create_cb) (void *io_device, void *ctx_buf)

I/O channel creation callback.

Parameters
io_deviceI/O device associated with this channel.
ctx_bufContext for the I/O device.

◆ spdk_io_channel_destroy_cb

typedef void(* spdk_io_channel_destroy_cb) (void *io_device, void *ctx_buf)

I/O channel destruction callback.

Parameters
io_deviceI/O device associated with this channel.
ctx_bufContext for the I/O device.

◆ spdk_io_device_unregister_cb

typedef void(* spdk_io_device_unregister_cb) (void *io_device)

I/O device unregister callback.

Parameters
io_deviceUnregistered I/O device.

◆ spdk_msg_fn

typedef void(* spdk_msg_fn) (void *ctx)

A function that will be called on the target thread.

Parameters
ctxContext passed as arg to spdk_thread_pass_msg().

◆ spdk_new_thread_fn

typedef int(* spdk_new_thread_fn) (struct spdk_thread *thread)

A function that is called each time a new thread is created.

The implementor of this function should frequently call spdk_thread_poll() on the thread provided.

Parameters
threadThe new spdk_thread.

◆ spdk_poller_fn

typedef int(* spdk_poller_fn) (void *ctx)

Callback function for a poller.

Parameters
ctxContext passed as arg to spdk_poller_register().
Returns
0 to indicate that polling took place but no events were found; positive to indicate that polling took place and some events were processed; negative if the poller does not provide spin-wait information.

◆ spdk_start_poller

typedef struct spdk_poller*(* spdk_start_poller) (void *thread_ctx, spdk_poller_fn fn, void *arg, uint64_t period_microseconds)

Function to be called to start a poller for the thread.

Parameters
thread_ctxContext for the thread.
fnCallback function for a poller.
argArgument passed to callback.
periodPolling period in microseconds.
Returns
a pointer to the poller on success, or NULL on failure.

◆ spdk_stop_poller

typedef void(* spdk_stop_poller) (struct spdk_poller *poller, void *thread_ctx)

Function to be called to stop a poller.

Parameters
pollerPoller to stop.
thread_ctxContext for the thread.

◆ spdk_thread_pass_msg

typedef void(* spdk_thread_pass_msg) (spdk_msg_fn fn, void *ctx, void *thread_ctx)

Function to be called to pass a message to a thread.

Parameters
fnCallback function for a thread.
ctxContext passed to fn.
thread_ctxContext for the thread.

Function Documentation

◆ spdk_for_each_channel()

void spdk_for_each_channel ( void *  io_device,
spdk_channel_msg  fn,
void *  ctx,
spdk_channel_for_each_cpl  cpl 
)

Call 'fn' on each channel associated with io_device.

This happens asynchronously, so fn may be called after spdk_for_each_channel returns. 'fn' will be called for each channel serially, such that two calls to 'fn' will not overlap in time. After 'fn' has been called, call spdk_for_each_channel_continue() to continue iterating.

Parameters
io_device'fn' will be called on each channel associated with this io_device.
fnCalled on the appropriate thread for each channel associated with io_device.
ctxContext buffer registered to spdk_io_channel_iter that can be obatined form the function spdk_io_channel_iter_get_ctx().
cplCalled on the thread that spdk_for_each_channel was initially called from when 'fn' has been called on each channel.

◆ spdk_for_each_channel_continue()

void spdk_for_each_channel_continue ( struct spdk_io_channel_iter *  i,
int  status 
)

Helper function to iterate all channels for spdk_for_each_channel().

Parameters
iI/O channel iterator.
statusStatus for the I/O channel iterator.

◆ spdk_for_each_thread()

void spdk_for_each_thread ( spdk_msg_fn  fn,
void *  ctx,
spdk_msg_fn  cpl 
)

Send a message to each thread, serially.

The message is sent asynchronously - i.e. spdk_for_each_thread will return prior to fn being called on each thread.

Parameters
fnThis is the function that will be called on each thread.
ctxThis context will be passed to fn when called.
cplThis will be called on the originating thread after fn has been called on each thread.

◆ spdk_get_io_channel()

struct spdk_io_channel* spdk_get_io_channel ( void *  io_device)

Get an I/O channel for the specified io_device to be used by the calling thread.

The io_device context pointer specified must have previously been registered using spdk_io_device_register(). If an existing I/O channel does not exist yet for the given io_device on the calling thread, it will allocate an I/O channel and invoke the create_cb function pointer specified in spdk_io_device_register(). If an I/O channel already exists for the given io_device on the calling thread, its reference is returned rather than creating a new I/O channel.

Parameters
io_deviceThe pointer to io_device context.
Returns
a pointer to the I/O channel for this device on success or NULL on failure.

◆ spdk_get_thread()

struct spdk_thread* spdk_get_thread ( void  )

Get a handle to the current thread.

This handle may be passed to other threads and used as the target of spdk_thread_send_msg().

See also
spdk_io_channel_get_thread()
Returns
a pointer to the current thread on success or NULL on failure.

◆ spdk_io_channel_from_ctx()

struct spdk_io_channel* spdk_io_channel_from_ctx ( void *  ctx)

Get I/O channel from the context buffer.

This is the inverse of spdk_io_channel_get_ctx().

Parameters
ctxThe pointer to the context buffer.
Returns
a pointer to the I/O channel associated with the context buffer.

◆ spdk_io_channel_get_ctx()

static void* spdk_io_channel_get_ctx ( struct spdk_io_channel ch)
inlinestatic

Get the context buffer associated with an I/O channel.

Parameters
chI/O channel.
Returns
a pointer to the context buffer.

◆ spdk_io_channel_get_thread()

struct spdk_thread* spdk_io_channel_get_thread ( struct spdk_io_channel ch)

Get the thread associated with an I/O channel.

Parameters
chI/O channel.
Returns
a pointer to the thread associated with the I/O channel

◆ spdk_io_channel_iter_get_channel()

struct spdk_io_channel* spdk_io_channel_iter_get_channel ( struct spdk_io_channel_iter *  i)

Get I/O channel from the I/O channel iterator.

Parameters
iI/O channel iterator.
Returns
a pointer to the I/O channel.

◆ spdk_io_channel_iter_get_ctx()

void* spdk_io_channel_iter_get_ctx ( struct spdk_io_channel_iter *  i)

Get context buffer from the I/O channel iterator.

Parameters
iI/O channel iterator.
Returns
a pointer to the context buffer.

◆ spdk_io_channel_iter_get_io_device()

void* spdk_io_channel_iter_get_io_device ( struct spdk_io_channel_iter *  i)

Get io_device from the I/O channel iterator.

Parameters
iI/O channel iterator.
Returns
a pointer to the io_device.

◆ spdk_io_device_register()

void spdk_io_device_register ( void *  io_device,
spdk_io_channel_create_cb  create_cb,
spdk_io_channel_destroy_cb  destroy_cb,
uint32_t  ctx_size,
const char *  name 
)

Register the opaque io_device context as an I/O device.

After an I/O device is registered, it can return I/O channels using the spdk_get_io_channel() function.

Parameters
io_deviceThe pointer to io_device context.
create_cbCallback function invoked to allocate any resources required for a new I/O channel.
destroy_cbCallback function invoked to release the resources for an I/O channel.
ctx_sizeThe size of the context buffer allocated to store references to allocated I/O channel resources.
nameA string name for the device used only for debugging. Optional - may be NULL.

◆ spdk_io_device_unregister()

void spdk_io_device_unregister ( void *  io_device,
spdk_io_device_unregister_cb  unregister_cb 
)

Unregister the opaque io_device context as an I/O device.

The actual unregistration might be deferred until all active I/O channels are destroyed.

Parameters
io_deviceThe pointer to io_device context.
unregister_cbAn optional callback function invoked to release any references to this I/O device.

◆ spdk_poller_pause()

void spdk_poller_pause ( struct spdk_poller *  poller)

Pause a poller on the current thread.

The poller is not run until it is resumed with spdk_poller_resume(). It is perfectly fine to pause an already paused poller.

Parameters
pollerThe poller to pause.

◆ spdk_poller_register()

struct spdk_poller* spdk_poller_register ( spdk_poller_fn  fn,
void *  arg,
uint64_t  period_microseconds 
)

Register a poller on the current thread.

The poller can be unregistered by calling spdk_poller_unregister().

Parameters
fnThis function will be called every period_microseconds.
argArgument passed to fn.
period_microsecondsHow often to call fn. If 0, call fn as often as possible.
Returns
a pointer to the poller registered on the current thread on success or NULL on failure.

◆ spdk_poller_register_named()

struct spdk_poller* spdk_poller_register_named ( spdk_poller_fn  fn,
void *  arg,
uint64_t  period_microseconds,
const char *  name 
)

Register a poller on the current thread with arbitrary name.

The poller can be unregistered by calling spdk_poller_unregister().

Parameters
fnThis function will be called every period_microseconds.
argArgument passed to fn.
period_microsecondsHow often to call fn. If 0, call fn as often as possible.
nameHuman readable name for the poller. Pointer of the poller function name is set if NULL.
Returns
a pointer to the poller registered on the current thread on success or NULL on failure.

◆ spdk_poller_resume()

void spdk_poller_resume ( struct spdk_poller *  poller)

Resume a poller on the current thread.

Resumes a poller paused with spdk_poller_pause(). It is perfectly fine to resume an unpaused poller.

Parameters
pollerThe poller to resume.

◆ spdk_poller_unregister()

void spdk_poller_unregister ( struct spdk_poller **  ppoller)

Unregister a poller on the current thread.

Parameters
ppollerThe poller to unregister.

◆ spdk_put_io_channel()

void spdk_put_io_channel ( struct spdk_io_channel ch)

Release a reference to an I/O channel.

This happens asynchronously.

This must be called on the same thread that called spdk_get_io_channel() for the specified I/O channel. If this releases the last reference to the I/O channel, The destroy_cb function specified in spdk_io_device_register() will be invoked to release any associated resources.

Parameters
chI/O channel to release a reference.

◆ spdk_set_thread()

void spdk_set_thread ( struct spdk_thread *  thread)

Force the current system thread to act as if executing the given SPDK thread.

Parameters
threadThe thread to set.

◆ spdk_thread_create()

struct spdk_thread* spdk_thread_create ( const char *  name,
struct spdk_cpuset cpumask 
)

Creates a new SPDK thread object.

Parameters
nameHuman-readable name for the thread; can be retrieved with spdk_thread_get_name(). The string is copied, so the pointed-to data only needs to be valid during the spdk_thread_create() call. May be NULL to specify no name.
cpumaskOptional mask of CPU cores on which to schedule this thread. This is only a suggestion to the scheduler. The value is copied, so cpumask may be released when this function returns. May be NULL if no mask is required.
Returns
a pointer to the allocated thread on success or NULL on failure..

◆ spdk_thread_destroy()

void spdk_thread_destroy ( struct spdk_thread *  thread)

Destroy a thread, releasing all of its resources.

May only be called on a thread previously marked as exited.

Parameters
threadThe thread to destroy.

◆ spdk_thread_exit()

int spdk_thread_exit ( struct spdk_thread *  thread)

Mark the thread as exited, failing all future spdk_thread_send_msg(), spdk_poller_register(), and spdk_get_io_channel() calls.

May only be called within an spdk poller or message.

All I/O channel references associated with the thread must be released using spdk_put_io_channel(), and all active pollers associated with the thread should be unregistered using spdk_poller_unregister(), prior to calling this function. This function will complete these processing. The completion can be queried by spdk_thread_is_exited().

Parameters
threadThe thread to destroy.
Returns
always 0. (return value was deprecated but keep it for ABI compatibility.)

◆ spdk_thread_get_by_id()

struct spdk_thread* spdk_thread_get_by_id ( uint64_t  id)

Get the thread by the ID.

Parameters
idID of the thread.
Returns
Thread whose ID matches or NULL otherwise.

◆ spdk_thread_get_cpumask()

struct spdk_cpuset* spdk_thread_get_cpumask ( struct spdk_thread *  thread)

Get the thread's cpumask.

Parameters
threadThe thread to get the cpumask for.
Returns
cpuset pointer

◆ spdk_thread_get_ctx()

void* spdk_thread_get_ctx ( struct spdk_thread *  thread)

Return a pointer to this thread's context.

Parameters
threadThe thread on which to get the context.
Returns
a pointer to the per-thread context, or NULL if there is no per-thread context.

◆ spdk_thread_get_from_ctx()

struct spdk_thread* spdk_thread_get_from_ctx ( void *  ctx)

Return the thread object associated with the context handle previously obtained by calling spdk_thread_get_ctx().

Parameters
ctxA context previously obtained by calling spdk_thread_get_ctx()
Returns
The associated thread.

◆ spdk_thread_get_id()

uint64_t spdk_thread_get_id ( const struct spdk_thread *  thread)

Get a thread's ID.

Parameters
threadThread to query.
Returns
the ID of the thread..

◆ spdk_thread_get_last_tsc()

uint64_t spdk_thread_get_last_tsc ( struct spdk_thread *  thread)

Return the TSC value from the end of the last time this thread was polled.

Parameters
threadThread to query.
Returns
TSC value from the end of the last time this thread was polled.

◆ spdk_thread_get_name()

const char* spdk_thread_get_name ( const struct spdk_thread *  thread)

Get a thread's name.

Parameters
threadThread to query.
Returns
the name of the thread.

◆ spdk_thread_get_stats()

int spdk_thread_get_stats ( struct spdk_thread_stats stats)

Get statistics about the current thread.

Copy cumulative thread stats values to the provided thread stats structure.

Parameters
statsUser's thread_stats structure.

◆ spdk_thread_has_active_pollers()

int spdk_thread_has_active_pollers ( struct spdk_thread *  thread)

Returns whether there are any active pollers (pollers for which period_microseconds equals 0) registered to be run on the thread.

Parameters
threadThe thread to check.
Returns
1 if there is at least one active poller, 0 otherwise.

◆ spdk_thread_has_pollers()

bool spdk_thread_has_pollers ( struct spdk_thread *  thread)

Returns whether there are any pollers registered to be run on the thread.

Parameters
threadThe thread to check.
Returns
true if there is any active poller, false otherwise.

◆ spdk_thread_is_exited()

bool spdk_thread_is_exited ( struct spdk_thread *  thread)

Returns whether the thread is marked as exited.

Parameters
threadThe thread to query.
Returns
true if marked as exited, false otherwise.

◆ spdk_thread_is_idle()

bool spdk_thread_is_idle ( struct spdk_thread *  thread)

Returns whether there are scheduled operations to be run on the thread.

Parameters
threadThe thread to check.
Returns
true if there are no scheduled operations, false otherwise.

◆ spdk_thread_lib_init()

int spdk_thread_lib_init ( spdk_new_thread_fn  new_thread_fn,
size_t  ctx_sz 
)

Initialize the threading library.

Must be called once prior to allocating any threads.

Parameters
new_thread_fnCalled each time a new SPDK thread is created. The implementor is expected to frequently call spdk_thread_poll() on the provided thread.
ctx_szFor each thread allocated, an additional region of memory of size ctx_size will also be allocated, for use by the thread scheduler. A pointer to this region may be obtained by calling spdk_thread_get_ctx().
Returns
0 on success. Negated errno on failure.

◆ spdk_thread_lib_init_ext()

int spdk_thread_lib_init_ext ( spdk_thread_op_fn  thread_op_fn,
spdk_thread_op_supported_fn  thread_op_supported_fn,
size_t  ctx_sz 
)

Initialize the threading library.

Must be called once prior to allocating any threads

Both thread_op_fn and thread_op_type_supported_fn have to be specified or not specified together.

Parameters
thread_op_fnCalled for SPDK thread operation.
thread_op_supported_fnCalled to check whether the SPDK thread operation is supported.
ctx_szFor each thread allocated, for use by the thread scheduler. A pointer to this region may be obtained by calling spdk_thread_get_ctx().
Returns
0 on success. Negated errno on failure.

◆ spdk_thread_next_poller_expiration()

uint64_t spdk_thread_next_poller_expiration ( struct spdk_thread *  thread)

Return the number of ticks until the next timed poller would expire.

Timed pollers are pollers for which period_microseconds is greater than 0.

Parameters
threadThe thread to check poller expiration times on
Returns
Number of ticks. If no timed pollers, return 0.

◆ spdk_thread_poll()

int spdk_thread_poll ( struct spdk_thread *  thread,
uint32_t  max_msgs,
uint64_t  now 
)

Perform one iteration worth of processing on the thread.

This includes both expired and continuous pollers as well as messages. If the thread has exited, return immediately.

Parameters
threadThe thread to process
max_msgsThe maximum number of messages that will be processed. Use 0 to process the default number of messages (8).
nowThe current time, in ticks. Optional. If 0 is passed, this function will call spdk_get_ticks() to get the current time. The current time is used as start time and this function will call spdk_get_ticks() at its end to know end time to measure run time of this function.
Returns
1 if work was done. 0 if no work was done.

◆ spdk_thread_send_critical_msg()

int spdk_thread_send_critical_msg ( struct spdk_thread *  thread,
spdk_msg_fn  fn 
)

Send a message to the given thread.

Only one critical message can be outstanding at the same time. It's intended to use this function in any cases that might interrupt the execution of the application, such as signal handlers.

The message will be sent asynchronously - i.e. spdk_thread_send_critical_msg will always return prior to fn being called.

Parameters
threadThe target thread.
fnThis function will be called on the given thread.
Returns
0 on success
-EIO if the message could not be sent to the destination thread, due to an already outstanding critical message

◆ spdk_thread_send_msg()

int spdk_thread_send_msg ( const struct spdk_thread *  thread,
spdk_msg_fn  fn,
void *  ctx 
)

Send a message to the given thread.

The message will be sent asynchronously - i.e. spdk_thread_send_msg will always return prior to fn being called.

Parameters
threadThe target thread.
fnThis function will be called on the given thread.
ctxThis context will be passed to fn when called.
Returns
0 on success
-ENOMEM if the message could not be allocated
-EIO if the message could not be sent to the destination thread

◆ spdk_thread_set_cpumask()

int spdk_thread_set_cpumask ( struct spdk_cpuset cpumask)

Set the current thread's cpumask to the specified value.

The thread may be rescheduled to one of the CPUs specified in the cpumask.

This API requires SPDK thread operation supports SPDK_THREAD_OP_RESCHED.

Parameters
cpumaskThe new cpumask for the thread.
Returns
0 on success, negated errno otherwise.