MCPcopy Create free account
hub / github.com/apache/brpc / bthread_id_cancel

Function bthread_id_cancel

src/bthread/id.cpp:489–511  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

487}
488
489int bthread_id_cancel(bthread_id_t id) {
490 bthread::Id* const meta = address_resource(bthread::get_slot(id));
491 if (!meta) {
492 return EINVAL;
493 }
494 uint32_t* butex = meta->butex;
495 const uint32_t id_ver = bthread::get_version(id);
496 meta->mutex.lock();
497 if (!meta->has_version(id_ver)) {
498 meta->mutex.unlock();
499 return EINVAL;
500 }
501 if (*butex != meta->first_ver) {
502 meta->mutex.unlock();
503 return EPERM;
504 }
505 *butex = meta->end_ver();
506 meta->first_ver = *butex;
507 meta->locked_ver = *butex;
508 meta->mutex.unlock();
509 return_resource(bthread::get_slot(id));
510 return 0;
511}
512
513int bthread_id_join(bthread_id_t id) {
514 const bthread::IdResourceId slot = bthread::get_slot(id);

Callers 2

ResetNonPodsMethod · 0.85
call_idMethod · 0.85

Calls 6

get_slotFunction · 0.70
get_versionFunction · 0.70
address_resourceFunction · 0.50
return_resourceFunction · 0.50
lockMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected