| 383 | } |
| 384 | |
| 385 | int ExecutionQueueBase::create(uint64_t* id, const ExecutionQueueOptions* options, |
| 386 | execute_func_t execute_func, |
| 387 | clear_task_mem clear_func, |
| 388 | void* meta, void* type_specific_function) { |
| 389 | if (execute_func == NULL || clear_func == NULL) { |
| 390 | return EINVAL; |
| 391 | } |
| 392 | |
| 393 | slot_id_t slot; |
| 394 | ExecutionQueueBase* const m = butil::get_resource(&slot, Forbidden()); |
| 395 | if (BAIDU_LIKELY(m != NULL)) { |
| 396 | m->_execute_func = execute_func; |
| 397 | m->_clear_func = clear_func; |
| 398 | m->_meta = meta; |
| 399 | m->_type_specific_function = type_specific_function; |
| 400 | CHECK(m->_head.load(butil::memory_order_relaxed) == NULL); |
| 401 | CHECK_EQ(0, m->_high_priority_tasks.load(butil::memory_order_relaxed)); |
| 402 | ExecutionQueueOptions opt; |
| 403 | if (options != NULL) { |
| 404 | opt = *options; |
| 405 | } |
| 406 | m->_options = opt; |
| 407 | m->_stopped.store(false, butil::memory_order_relaxed); |
| 408 | m->_this_id = make_id( |
| 409 | _version_of_vref(m->_versioned_ref.fetch_add( |
| 410 | 1, butil::memory_order_release)), slot); |
| 411 | *id = m->_this_id; |
| 412 | m->_pthread_started = false; |
| 413 | m->_current_head = NULL; |
| 414 | get_execq_vars()->execq_count << 1; |
| 415 | return 0; |
| 416 | } |
| 417 | return ENOMEM; |
| 418 | } |
| 419 | |
| 420 | inline bool TaskIteratorBase::should_break_for_high_priority_tasks() { |
| 421 | if (!_high_priority && |
nothing calls this directly
no test coverage detected