MCPcopy Create free account
hub / github.com/Netis/cloud-probe / task_manager_new

Function task_manager_new

cpworker/src/task.c:321–411  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

319}
320
321static int task_manager_new(task_manager_t *this, Config *config)
322{
323 this->execution_model = config->execution_model;
324 if (this->execution_model == EXECUTION_MODEL_PIPELINE)
325 {
326 this->ring = spsc_ring_create(1024 * 1024);
327 if (!this->ring)
328 {
329 log_fatal("create spsc_ring_t failed");
330 return -1;
331 }
332
333 this->alloc = simple_allocator_create(config->pipeline.buffer_size_mb * 1024 * 1024);
334 if (!this->alloc)
335 {
336 log_fatal("create simple_allocator_t failed");
337 spsc_ring_destroy(this->ring);
338 return -1;
339 }
340 }
341 else
342 {
343 this->ring = NULL;
344 this->alloc = NULL;
345 }
346
347 this->tasks = malloc(sizeof(struct TaskList));
348 if (!this->tasks)
349 {
350 log_fatal("malloc failed");
351 if (this->ring)
352 spsc_ring_destroy(this->ring);
353 if (this->alloc)
354 simple_allocator_destroy(this->alloc);
355 return -1;
356 }
357 this->errors = malloc(sizeof(struct TaskErrorList));
358 if (!this->errors)
359 {
360 free(this->tasks);
361 if (this->ring)
362 spsc_ring_destroy(this->ring);
363 if (this->alloc)
364 simple_allocator_destroy(this->alloc);
365 log_fatal("malloc failed");
366 return -1;
367 }
368
369 this->config = config;
370 TAILQ_INIT(this->tasks);
371 TAILQ_INIT(this->errors);
372
373 pthread_mutex_init(&this->stats_lock, NULL);
374
375 int num_tasks = config->tasks_cfg->num_tasks;
376 log_info("find %d tasks", num_tasks);
377
378 int inited_count = 0;

Callers 1

task_manager_initFunction · 0.85

Calls 9

spsc_ring_createFunction · 0.85
simple_allocator_createFunction · 0.85
spsc_ring_destroyFunction · 0.85
simple_allocator_destroyFunction · 0.85
capture_task_newFunction · 0.85
task_error_newFunction · 0.85
task_manager_destroyFunction · 0.85
task_wrapper_newFunction · 0.85
capture_task_destroyFunction · 0.85

Tested by

no test coverage detected