engine.h

Source file: engine.h

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Function: engine_init

int engine_init(unsigned int flags)

Initialize the engine subsystem.

Must be called before engine_run. Configure with engine_config first.

Parameters:

Name Type Description
flags unsigned int Initialization flags.

Returns: 0 on success, negative on error.

Appendix

How To:

Always call engine_init() before any other engine function. Use ENGINE_DEBUG flag for debug logging, ENGINE_TRACE for call tracing. After initialization, configure with engine_config and call engine_run().

!!! warning "Note" Thread safety: engine_init() is not thread-safe. Call it exactly once from the main thread before spawning workers. On some platforms, calling engine_init() after engine_shutdown() may leak file descriptors.

Example usage in code

engine_test.c:4
static void test_basic_startup(void)
{
    int ret;

    ret = engine_init(0);
    igt_assert(ret == 0);

    engine_shutdown();
}
engine_test.c:17
static void test_debug_mode(void)
{
    struct engine_config cfg = {
        .max_threads = 2,
        .debug = 1,
    };

    engine_init(ENGINE_DEBUG);
    engine_run(&cfg);
    engine_shutdown();
}

Function: engine_shutdown

void engine_shutdown(void)

Shut down the engine and release resources.

Safe to call even if engine_init was never called.

Appendix

Example usage in code

engine_test.c:4
static void test_basic_startup(void)
{
    int ret;

    ret = engine_init(0);
    igt_assert(ret == 0);

    engine_shutdown();
}
engine_test.c:17
static void test_debug_mode(void)
{
    struct engine_config cfg = {
        .max_threads = 2,
        .debug = 1,
    };

    engine_init(ENGINE_DEBUG);
    engine_run(&cfg);
    engine_shutdown();
}

Function: engine_get_name

const char *engine_get_name(struct engine_config *engine)
Example
const char *name = engine_get_name();
printf("Engine: %s\n", name);

Get the engine name string.

Returns a pointer to the internal name buffer. Do not free.

Parameters:

Name Type Description
engine struct engine_config * Engine instance.

Returns: Pointer to null-terminated name string.


Function: __engine_reset

void __engine_reset(void *ctx)

Internal helper, not part of public API.

Resets the engine state back to its initial configuration. All pending operations are cancelled and buffers are flushed.

Parameters:

Name Type Description
ctx void * Internal context.

Appendix

How To:

Call after catching an unrecoverable error to restore a clean state. Always pair with engine_init() afterwards to reinitialize.

!!! warning "Note" This is an internal function — prefer engine_shutdown() followed by engine_init() in application code. Calling with a NULL ctx is a no-op.


Struct: engine_config

struct engine_config

Engine configuration.

Pass to engine_run to control behavior.


max_threads

int max_threads

Maximum number of worker threads.


debug

int debug

Enable debug tracing. Set to TRUE to enable.