Struct faiss::TimeoutCallback

struct TimeoutCallback : public faiss::InterruptCallback

Public Functions

virtual bool want_interrupt() override
void set_timeout(double timeout_in_seconds)

Public Members

std::chrono::time_point<std::chrono::steady_clock> start
double timeout

Public Static Functions

static void reset(double timeout_in_seconds)
static void clear_instance()
static void check()

check if:

  • an interrupt callback is set

  • the callback returns true if this is the case, then throw an exception. Should not be called from multiple threads.

static bool is_interrupted()

same as check() but return true if is interrupted instead of throwing. Can be called from multiple threads.

static size_t get_period_hint(size_t flops)

assuming each iteration takes a certain number of flops, what is a reasonable interval to check for interrupts?

Public Static Attributes

static std::mutex lock
static std::unique_ptr<InterruptCallback> instance