MCPcopy Create free account
hub / github.com/Tencent/libco / Producer

Function Producer

example_cond.cpp:34–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32 queue<stTask_t*> task_queue;
33};
34void* Producer(void* args)
35{
36 co_enable_hook_sys();
37 stEnv_t* env= (stEnv_t*)args;
38 int id = 0;
39 while (true)
40 {
41 stTask_t* task = (stTask_t*)calloc(1, sizeof(stTask_t));
42 task->id = id++;
43 env->task_queue.push(task);
44 printf("%s:%d produce task %d\n", __func__, __LINE__, task->id);
45 co_cond_signal(env->cond);
46 poll(NULL, 0, 1000);
47 }
48 return NULL;
49}
50void* Consumer(void* args)
51{
52 co_enable_hook_sys();

Callers

nothing calls this directly

Calls 3

co_enable_hook_sysFunction · 0.85
co_cond_signalFunction · 0.85
pollFunction · 0.85

Tested by

no test coverage detected