| 1334 | } |
| 1335 | |
| 1336 | CallId Controller::call_id() { |
| 1337 | butil::atomic<uint64_t>* target = |
| 1338 | (butil::atomic<uint64_t>*)&_correlation_id.value; |
| 1339 | uint64_t loaded = target->load(butil::memory_order_relaxed); |
| 1340 | if (loaded) { |
| 1341 | const CallId id = { loaded }; |
| 1342 | return id; |
| 1343 | } |
| 1344 | // Optimistic locking. |
| 1345 | CallId cid = { 0 }; |
| 1346 | // The range of this id will be reset in Channel::CallMethod |
| 1347 | CHECK_EQ(0, bthread_id_create2(&cid, this, HandleSocketFailed)); |
| 1348 | if (!target->compare_exchange_strong(loaded, cid.value, |
| 1349 | butil::memory_order_relaxed)) { |
| 1350 | bthread_id_cancel(cid); |
| 1351 | cid.value = loaded; |
| 1352 | } |
| 1353 | return cid; |
| 1354 | } |
| 1355 | |
| 1356 | void Controller::SaveClientSettings(ClientSettings* s) const { |
| 1357 | s->timeout_ms = _timeout_ms; |