Skip to content

Commit

Permalink
smalll changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
joka921 committed Feb 1, 2024
1 parent 4ef4493 commit 6a825bc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 30 deletions.
7 changes: 0 additions & 7 deletions src/index/Vocabulary.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,6 @@ class Vocabulary {

virtual ~Vocabulary() = default;

/*
//! clear all the contents, but not the settings for prefixes etc
void clear() {
internalVocabulary_.close();
externalVocabulary_.close();
}
*/
//! Read the vocabulary from file.
void readFromFile(const string& fileName, const string& extLitsFileName = "");

Expand Down
11 changes: 6 additions & 5 deletions src/util/Consumerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,21 @@
namespace ad_utility {
/*
This implements `Consumerators` which are in some sense the opposite of
`generators`. This is best explained by an EDxample: ConsumeratorImpl<int>
somethingNumeric(int& target) {
`generators`. This is best explained by an Example:
ConsumeratorImpl<int> somethingNumeric(int& target) {
// Initial portion of the code, executed during the construction phase
int a = 0;
int b = target + 24;
// The inner loop, the structure of the `co_await`s must be always like this,
otherwise you get undefined behavior. while (co_await valueWasPushedTag) {
// The inner loop, the structure of the `co_await`s must be always like
//this, otherwise you get undefined behavior.
while (co_await valueWasPushedTag) {
// This loop sees all the values that are `push`ed to the `Consumerator`.
int val = co_await nextValueTag;
a += val;
b *= a;
}
// Remaining final code, will be executed when `finish` or the destructor is
called, whichever happens first.
// called, whichever happens first.
// In our somewhat artificial example we write back a final result:
target = a / b;
}
Expand Down
17 changes: 0 additions & 17 deletions src/util/ExceptionHandling.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,4 @@ void terminateIfThrows(F&& f, std::string_view message,
logAndTerminate(msg);
}
}

struct ThrowIfSafe {
private:
int numExceptionsDuringConstruction_ = std::uncaught_exceptions();

public:
void throwIfSafe(auto&& f, auto&&... args) {
try {
std::invoke(AD_FWD(f), AD_FWD(args)...);
} catch (...) {
if (std::uncaught_exceptions() == numExceptionsDuringConstruction_) {
throw;
}
// TODO<joka921> Log if an exception occured.
}
}
};
} // namespace ad_utility
2 changes: 1 addition & 1 deletion test/ConsumeratorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#include "util/Consumerator.h"

using ad_utility::ConsumeratorImpl;
using ad_utility::Consumerator;
using ad_utility::ConsumeratorImpl;

template <auto make>
constexpr auto makeWrapper =
Expand Down

0 comments on commit 6a825bc

Please sign in to comment.