Groonga
Loading...
Searching...
No Matches
thread.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef uint32_t(* grn_thread_get_limit_func) (void *data)
 The function pointer type that returns the max number of threads.
 
typedef void(* grn_thread_set_limit_func) (uint32_t new_limit, void *data)
 The function pointer type that sets the max number of threads.
 
typedef uint32_t(* grn_thread_get_limit_with_ctx_func) (grn_ctx *ctx, void *data)
 
typedef void(* grn_thread_set_limit_with_ctx_func) (grn_ctx *ctx, uint32_t new_limit, void *data)
 

Functions

GRN_API uint32_t grn_thread_get_limit (void)
 Get the max number of threads.
 
GRN_API void grn_thread_set_limit (uint32_t new_limit)
 Set the max number of threads.
 
GRN_API uint32_t grn_thread_get_limit_with_ctx (grn_ctx *ctx)
 
GRN_API void grn_thread_set_limit_with_ctx (grn_ctx *ctx, uint32_t new_limit)
 
GRN_API void grn_thread_set_get_limit_func (grn_thread_get_limit_func func, void *data)
 Set the custom function that returns the max number of threads.
 
GRN_API void grn_thread_set_set_limit_func (grn_thread_set_limit_func func, void *data)
 Set the custom function that sets the max number of threads.
 
GRN_API void grn_thread_set_get_limit_with_ctx_func (grn_thread_get_limit_with_ctx_func func, void *data)
 
GRN_API void grn_thread_set_set_limit_with_ctx_func (grn_thread_set_limit_with_ctx_func func, void *data)
 
GRN_API grn_rc grn_thread_dump (grn_ctx *ctx)
 

Typedef Documentation

◆ grn_thread_get_limit_func

typedef uint32_t(* grn_thread_get_limit_func) (void *data)

The function pointer type that returns the max number of threads.

Since
5.0.7

This is the function pointer type for custom functions that return the maximum number of threads. When set via grn_thread_set_get_limit_func, this function will be called by grn_thread_get_limit.

Parameters
dataUser data passed when the function was registered.
Returns
The max number of threads.

◆ grn_thread_get_limit_with_ctx_func

typedef uint32_t(* grn_thread_get_limit_with_ctx_func) (grn_ctx *ctx, void *data)

◆ grn_thread_set_limit_func

typedef void(* grn_thread_set_limit_func) (uint32_t new_limit, void *data)

The function pointer type that sets the max number of threads.

Since
5.0.7

This is the function pointer type for custom functions that set the maximum number of threads. When set via grn_thread_set_set_limit_func, this function will be called by grn_thread_set_limit.

Parameters
new_limitThe new max number of threads to set.
dataUser data passed when the function was registered.

◆ grn_thread_set_limit_with_ctx_func

typedef void(* grn_thread_set_limit_with_ctx_func) (grn_ctx *ctx, uint32_t new_limit, void *data)

Function Documentation

◆ grn_thread_dump()

GRN_API grn_rc grn_thread_dump ( grn_ctx ctx)

◆ grn_thread_get_limit()

GRN_API uint32_t grn_thread_get_limit ( void  )

Get the max number of threads.

If grn_thread_get_limit_func isn't set by grn_thread_set_get_limit_func, it always returns 0.

Returns
The max number of threads or 0.

◆ grn_thread_get_limit_with_ctx()

GRN_API uint32_t grn_thread_get_limit_with_ctx ( grn_ctx ctx)

◆ grn_thread_set_get_limit_func()

GRN_API void grn_thread_set_get_limit_func ( grn_thread_get_limit_func  func,
void *  data 
)

Set the custom function that returns the max number of threads.

Since
5.0.7

This function sets a custom function that will be called when grn_thread_get_limit is invoked. The custom function allows applications to dynamically control the thread limit.

data is passed to func when func is called from grn_thread_get_limit.

For example usage:

static uint32_t
my_get_thread_limit(void *data)
{
uint32_t *max_threads = (uint32_t *)data;
return *max_threads;
}
uint32_t max_threads = 100;
grn_thread_set_get_limit_func(my_get_thread_limit, &max_threads);
GRN_API void grn_thread_set_get_limit_func(grn_thread_get_limit_func func, void *data)
Set the custom function that returns the max number of threads.
Parameters
funcThe custom function that returns the max number of threads.
dataUser data to be passed to func when func is called.

◆ grn_thread_set_get_limit_with_ctx_func()

GRN_API void grn_thread_set_get_limit_with_ctx_func ( grn_thread_get_limit_with_ctx_func  func,
void *  data 
)

◆ grn_thread_set_limit()

GRN_API void grn_thread_set_limit ( uint32_t  new_limit)

Set the max number of threads.

If grn_thread_set_limit_func isn't set by grn_thread_set_set_limit_func, it does nothing.

Parameters
new_limitThe new max number of threads.

◆ grn_thread_set_limit_with_ctx()

GRN_API void grn_thread_set_limit_with_ctx ( grn_ctx ctx,
uint32_t  new_limit 
)

◆ grn_thread_set_set_limit_func()

GRN_API void grn_thread_set_set_limit_func ( grn_thread_set_limit_func  func,
void *  data 
)

Set the custom function that sets the max number of threads.

Since
5.0.7

This function sets a custom function that will be called when grn_thread_set_limit is invoked. The custom function allows applications to handle thread limit changes.

data is passed to func when func is called from grn_thread_set_limit.

For example usage:

static uint32_t current_thread_limit = 0;
static void
my_set_thread_limit(uint32_t new_limit, void *data)
{
uint32_t *max_n_threads = (uint32_t *)data;
if (new_limit <= *max_n_threads) {
current_thread_limit = new_limit;
} else {
current_thread_limit = *max_n_threads;
}
}
uint32_t max_allowed_threads = 50;
grn_thread_set_set_limit_func(my_set_thread_limit, &max_allowed_threads);
grn_thread_set_limit(30); // Sets to 30 (within allowed range)
grn_thread_set_limit(100); // Sets to 50 (capped at max_allowed_threads
value)
GRN_API void grn_thread_set_limit(uint32_t new_limit)
Set the max number of threads.
GRN_API void grn_thread_set_set_limit_func(grn_thread_set_limit_func func, void *data)
Set the custom function that sets the max number of threads.
Parameters
funcThe custom function that sets the max number of threads.
dataUser data to be passed to func when func is called.

◆ grn_thread_set_set_limit_with_ctx_func()

GRN_API void grn_thread_set_set_limit_with_ctx_func ( grn_thread_set_limit_with_ctx_func  func,
void *  data 
)