nfs-ganesha - thread model - fridgethr

fridgethr(fridge thread)是一个叫Philippe设计的工作者/消费者模型,在2.7的修改中一部分被work pool代替。之所以叫fridge,是当线程无事可做的时候被freeze住。参考
fridgethr是nfs-ganesha提供的
work pool是ntiprc提供的

函数

  • fridgethr_init
  • fridgethr_submit 生产者

使用场景

pooling

struct fridgethr_params frp;

frp.thr_max = 1;
frp.thr_min = 1;
frp.thread_delay = reaper_delay; //每次循环中间delay的时间
frp.flavor = fridgethr_flavor_looper;//在线程中循环调用给定函数

rc = fridgethr_init(&reaper_fridge, "reaper", &frp);
rc = fridgethr_submit(reaper_fridge, reaper_run, &reaper_state); //循环调用reaper_run

worker

//init
frp.thr_max = 1;
frp.deferment = fridgethr_defer_queue;
rc = fridgethr_init(&state_async_fridge, "State_Async", &frp);
//submit
rc = fridgethr_submit(state_async_fridge, state_async_func_caller, arg);

//用作worker thread
rc = fridgethr_populate(worker_fridge, worker_run, NULL);

你可能感兴趣的:(nfs-ganesha - thread model - fridgethr)