mirror of
https://github.com/apple/foundationdb.git
synced 2025-06-01 10:45:56 +08:00
Ban Void _ = wait(...)
constructions, and require just wait(...)
.
There's never any reason to save the value of a Void return, and it's the easiest source of redefined variable bugs that will creep back in over time. So just `wait(...)`, it's cleaner that way.
This commit is contained in:
parent
86dbe1f0e9
commit
63b1e85338
@ -1322,7 +1322,7 @@ ACTOR Future<Void> runDBAgent(Database src, Database dest) {
|
||||
|
||||
loop {
|
||||
try {
|
||||
state Void run = wait(backupAgent.run(dest, &pollDelay, CLIENT_KNOBS->BACKUP_TASKS_PER_AGENT));
|
||||
wait(backupAgent.run(dest, &pollDelay, CLIENT_KNOBS->BACKUP_TASKS_PER_AGENT));
|
||||
break;
|
||||
}
|
||||
catch (Error& e) {
|
||||
@ -1347,7 +1347,7 @@ ACTOR Future<Void> runAgent(Database db) {
|
||||
|
||||
loop {
|
||||
try {
|
||||
state Void run = wait(backupAgent.run(db, &pollDelay, CLIENT_KNOBS->BACKUP_TASKS_PER_AGENT));
|
||||
wait(backupAgent.run(db, &pollDelay, CLIENT_KNOBS->BACKUP_TASKS_PER_AGENT));
|
||||
break;
|
||||
}
|
||||
catch (Error& e) {
|
||||
|
@ -347,7 +347,7 @@ class throwF2(throwF):
|
||||
|
||||
class throwF3(throwF):
|
||||
def __str__(self):
|
||||
return indent(self.cx) + "Void _ = wait( error ); // throw operation_failed()\n"
|
||||
return indent(self.cx) + "wait( error ); // throw operation_failed()\n"
|
||||
|
||||
def unreachable(self):
|
||||
return False # The actor compiler doesn't know that 'error' always contains an error
|
||||
|
@ -30,7 +30,7 @@
|
||||
// effect outside simulation.
|
||||
// Typical use is something like:
|
||||
// debug_advanceMaxCommittedVersion( self->id, version );
|
||||
// Void _ = wait( commit(version) );
|
||||
// wait( commit(version) );
|
||||
// debug_advanceMinCommittedVersion( self->id, version );
|
||||
// and then a call to debug_checkRestoredVersion() after some kind of reboot or recovery event
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "flow/actorcompiler.h" // This must be the last #include.
|
||||
#include "flow/ActorCollection.h"
|
||||
#include "DataDistribution.h"
|
||||
#include "fdbclient/SystemData.h"
|
||||
@ -32,6 +31,7 @@
|
||||
#include "fdbclient/ManagementAPI.h"
|
||||
#include "fdbrpc/Replication.h"
|
||||
#include "flow/UnitTest.h"
|
||||
#include "flow/actorcompiler.h" // This must be the last #include.
|
||||
|
||||
class TCTeamInfo;
|
||||
|
||||
|
@ -147,7 +147,7 @@ ACTOR Future<Void> runBackup( Reference<ClusterConnectionFile> connFile ) {
|
||||
}
|
||||
}
|
||||
|
||||
Void _= wait(Future<Void>(Never()));
|
||||
wait(Future<Void>(Never()));
|
||||
throw internal_error();
|
||||
}
|
||||
|
||||
@ -188,7 +188,7 @@ ACTOR Future<Void> runDr( Reference<ClusterConnectionFile> connFile ) {
|
||||
}
|
||||
}
|
||||
|
||||
Void _= wait(Future<Void>(Never()));
|
||||
wait(Future<Void>(Never()));
|
||||
throw internal_error();
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ public:
|
||||
|
||||
ACTOR Future<Void> performTest(Database cx, Standalone<VectorRef<KeyValueRef>> data, ApiCorrectnessWorkload *self) {
|
||||
//Run the scripted test for a maximum of 10 minutes
|
||||
Void _scripted = wait(timeout(self->runScriptedTest(self, data), 600, Void()));
|
||||
wait(timeout(self->runScriptedTest(self, data), 600, Void()));
|
||||
|
||||
if(!self->hasFailed()) {
|
||||
//Return database to original state (for a maximum of 1800 seconds)
|
||||
@ -169,7 +169,7 @@ public:
|
||||
}
|
||||
|
||||
//Run the random test for the user-specified duration
|
||||
Void _random = wait(timeout(self->runRandomTest(self, data), self->randomTestDuration, Void()));
|
||||
wait(timeout(self->runRandomTest(self, data), self->randomTestDuration, Void()));
|
||||
}
|
||||
|
||||
return Void();
|
||||
@ -335,7 +335,7 @@ public:
|
||||
break;
|
||||
}
|
||||
catch(Error &e) {
|
||||
Void _ = wait(transaction->onError(e));
|
||||
wait(transaction->onError(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ struct AsyncFileCorrectnessWorkload : public AsyncFileWorkload
|
||||
self->fileSize = 0;
|
||||
|
||||
//Create or open the file being used for testing
|
||||
Void _ = wait(self->openFile(self, IAsyncFile::OPEN_READWRITE | IAsyncFile::OPEN_CREATE, 0666, self->fileSize, true));
|
||||
wait(self->openFile(self, IAsyncFile::OPEN_READWRITE | IAsyncFile::OPEN_CREATE, 0666, self->fileSize, true));
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ ACTOR static Future<vector<pair<uint64_t, double> > > trackInsertionCount(Databa
|
||||
{
|
||||
state Future<Standalone<RangeResultRef>> countFuture = tr.getRange(keyPrefix, 1000000000);
|
||||
state Future<Standalone<RangeResultRef>> bytesFuture = tr.getRange(bytesPrefix, 1000000000);
|
||||
Void __ = wait(success(countFuture) && success(bytesFuture));
|
||||
wait(success(countFuture) && success(bytesFuture));
|
||||
|
||||
Standalone<RangeResultRef> counts = countFuture.get();
|
||||
Standalone<RangeResultRef> bytes = bytesFuture.get();
|
||||
|
@ -96,7 +96,7 @@ struct IndexScanWorkload : KVWorkload {
|
||||
state double start = now();
|
||||
try {
|
||||
loop {
|
||||
Void _ = wait( scanDatabase( cx, self ) );
|
||||
wait( scanDatabase( cx, self ) );
|
||||
}
|
||||
} catch( ... ) {
|
||||
self->totalTimeFetching = now() - start;
|
||||
|
@ -520,7 +520,7 @@ struct ReadWriteWorkload : KVWorkload {
|
||||
state UID debugID;
|
||||
|
||||
if (self->rampUpConcurrency) {
|
||||
Void _ = wait( ::delay( self->testDuration/2 * (double(clientIndex) / self->actorCount + double(self->clientId) / self->clientCount / self->actorCount) ) );
|
||||
wait( ::delay( self->testDuration/2 * (double(clientIndex) / self->actorCount + double(self->clientId) / self->clientCount / self->actorCount) ) );
|
||||
TraceEvent("ClientStarting").detail("ActorIndex", clientIndex).detail("ClientIndex", self->clientId).detail("NumActors", clientIndex*self->clientCount + self->clientId + 1);
|
||||
}
|
||||
|
||||
|
@ -556,6 +556,11 @@ namespace actorcompiler
|
||||
bool constructorSyntax;
|
||||
ParseDeclaration( toks.RevSkipWhile(t=>t.Value==";"), out name, out type, out initializer, out constructorSyntax );
|
||||
|
||||
string typestring = str(NormalizeWhitespace(type));
|
||||
if (typestring == "Void") {
|
||||
throw new Error(ws.FirstSourceLine, "Assigning the result of a Void wait is not allowed. Just use a standalone wait statement.");
|
||||
}
|
||||
|
||||
ws.result = new VarDeclaration
|
||||
{
|
||||
name = name.Value,
|
||||
|
Loading…
x
Reference in New Issue
Block a user