eyBuildLib API Reference : eyBuildLib

ebthreadpool

NAME

ebthreadpool - a flexible thread pool library

ROUTINES

ebThreadPoolCreate( ) - create a static thread pool
ebThreadPoolJobAdd( ) - add a job into thread pool
ebThreadPoolDestroy( ) - destroy thread pool
ebThreadPoolGetRequests( ) - gets the request in queue of thread pool
ebThreadPoolActiveThreads( ) - gets the number of Active threads in thread pool

DESCRIPTION

This library support Win32, POSIX OS and VxWorks.

INCLUDE

ebthreadpool.h ebthread.h


eyBuildLib : Routines

ebThreadPoolCreate( )

NAME

ebThreadPoolCreate( ) - create a static thread pool

SYNOPSIS

EBTHREAD_POOL * ebThreadPoolCreate
    (
    EBTHREAD_ATTR * pattr,       /* thread attribute */
    size_t          threads_num, /* threads number in thread pool */
    size_t          queue_len    /* length of request queue */
    )

DESCRIPTION

This routine is to create a static thread pool, which has threads_num work threads. Before call ebThreadPoolJobAdd( ) all work threads are waiting a ready queue.

RETURN

OK, ERROR if no enough resource in system.

SEE ALSO

ebthreadpool


eyBuildLib : Routines

ebThreadPoolJobAdd( )

NAME

ebThreadPoolJobAdd( ) - add a job into thread pool

SYNOPSIS

int ebThreadPoolJobAdd
    (
    EBTHREAD_POOL * pool,     /* thread pool ID */
    unsigned long   timeout,  /* wait microseconds if queue empty */
    EBCALLBACK      callback, /* job callback routine */
    void *          arg1,
    void *          arg2,
    void *          arg3,
    void *          arg4,
    void *          arg5
    )

DESCRIPTION

This routine adds a new job into thread pool. It will be blocked at most timeout millisecond if the wait queue is full. When there has free thread, it will pick up the first request in the wait queue and execute the callback.

RETURN

OK, ERROR or EBTIMEOUT

SEE ALSO

ebthreadpool


eyBuildLib : Routines

ebThreadPoolDestroy( )

NAME

ebThreadPoolDestroy( ) - destroy thread pool

SYNOPSIS

int ebThreadPoolDestroy
    (
    EBTHREAD_POOL * pool
    )

DESCRIPTION

This routine destroy thread pool and release all resource. It first try to informs all work thread exit; After all work threads exit, it frees the all resources in thread pool. Note, user should stop call ebThreadPoolJobAdd( ) when call this routine in multi-threads invironment.

RETURN

OK/ERROR

SEE ALSO

ebthreadpool


eyBuildLib : Routines

ebThreadPoolGetRequests( )

NAME

ebThreadPoolGetRequests( ) - gets the request in queue of thread pool

SYNOPSIS

int ebThreadPoolGetRequests
    (
    EBTHREAD_POOL * pool
    )

DESCRIPTION

This routine get the request in queue of thread pool.

RETURN

numuber of requests in queue, or ERROR

SEE ALSO

ebthreadpool


eyBuildLib : Routines

ebThreadPoolActiveThreads( )

NAME

ebThreadPoolActiveThreads( ) - gets the number of Active threads in thread pool

SYNOPSIS

int ebThreadPoolActiveThreads
    (
    EBTHREAD_POOL * pool
    )

DESCRIPTION

This routine gets the number of Active threads in thread pool.

RETURN

numuber of idle threads, or ERROR

SEE ALSO

ebthreadpool