Skip to content

kritma/tread_pool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

simple thread pool

#include "thread_pool.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

void print_val(void *val) {
  const int ms100 = 1000 * 1;
  usleep(ms100);
  printf("%d\n", *(int *)val);
  free(val);
}

int main() {
  threadpool_t *pool = threadpool_create(10, 50);
  for (int i = 0; i < 40; i++) {
    int *val = malloc(sizeof(int));
    *val = i;
    threadpool_run(pool, print_val, val);
  }
  threadpool_destroy(pool, 1);
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages