MCPcopy Create free account
hub / github.com/apple/foundationdb / setTimeout

Method setTimeout

fdbclient/MultiVersionTransaction.actor.cpp:1499–1525  ·  view source on GitHub ↗

Configure a timeout based on the options set for this transaction. This timeout only applies if we don't have an underlying database object to connect with.

Source from the content-addressed store, hash-verified

1497// Configure a timeout based on the options set for this transaction. This timeout only applies
1498// if we don't have an underlying database object to connect with.
1499void MultiVersionTransaction::setTimeout(Optional<StringRef> value) {
1500 double timeoutDuration = extractIntOption(value, 0, std::numeric_limits<int>::max()) / 1000.0;
1501
1502 ThreadFuture<Void> prevTimeout;
1503 double transactionStartTime = startTime;
1504
1505 { // lock scope
1506 ThreadSpinLockHolder holder(timeoutLock);
1507 prevTimeout = currentTimeout;
1508
1509 if (timeoutDuration > 0) {
1510 Reference<ThreadSingleAssignmentVar<Void>> tsav = timeoutTsav;
1511 ThreadFuture<Void> newTimeout = onMainThread([transactionStartTime, tsav, timeoutDuration]() {
1512 return timeoutImpl(tsav, timeoutDuration - std::max(0.0, now() - transactionStartTime));
1513 });
1514 currentTimeout = newTimeout;
1515 } else {
1516 currentTimeout = ThreadFuture<Void>();
1517 }
1518 }
1519
1520 // Cancel the previous timeout now that we have a new one. This means that changing the timeout
1521 // affects in-flight operations, which is consistent with the behavior in RYW.
1522 if (prevTimeout.isValid()) {
1523 prevTimeout.cancel();
1524 }
1525}
1526
1527// Creates a ThreadFuture<T> that will signal an error if the transaction times out.
1528template <class T>

Callers 4

addUUIDConflictsMethod · 0.45
processInstructionMethod · 0.45
processInstructionMethod · 0.45
testLocalityMethod · 0.45

Calls 5

nowFunction · 0.85
extractIntOptionFunction · 0.70
cancelMethod · 0.65
onMainThreadFunction · 0.50
isValidMethod · 0.45

Tested by 4

addUUIDConflictsMethod · 0.36
processInstructionMethod · 0.36
processInstructionMethod · 0.36
testLocalityMethod · 0.36