Code Monkey home page Code Monkey logo

thpool's Introduction

thpool

test.c : 这是一个简单的测试程序

Threads are only for Linux and Unix,(该线程池只适用于linux和unix)

This is a lightweight, completely unlocked thread pool,(这是一个轻量级完全无锁的线程池)

The default task queue size is 1024(默认任务队列的大小是102)

The task queue size API will be switched out later(后续会将任务队列大小的API开换出来)

创建线程

@capacity 线程池的容量

@thsize 初始线程数量 必须小于等于线程池容量

@thpool 返回线程池指针

thpool * thpool_init(uint_t capacity,uint_t thsize);

添加任务

创建的线程池指针

@job 要添加的任务

void thpool_add_task(thpool *pool, job *job);

增加线程数量

@pool 线程池指针

@thsize 要增加的线程数量 总数量不能大于线程容量

@return 返回成功增加的线程数量

uint_t thpool_add_thread(thpool * pool, uint_t thsize);

减少线程数量

@pool 线程池指针

@thsize 要减少的线程池数量

@return 实际减少的线程数量

uint_t thpool_sub_thread(thpool * pool, uint_t thsize);

返回在工作的线程数量

uint_t thpool_get_thread();

销毁线程池

@pool 创建要销毁的线程池指针

void thpool_destroy(thpool *pool);

thpool's People

Contributors

mt21625457 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.