Lucene++ - a full-featured, c++ search engine
API Documentation


Loading...
Searching...
No Matches
Static Public Member Functions
Lucene::SearchCancellation Class Reference

Global search cancellation context using thread-local storage. More...

#include <SearchCancellation.h>

Static Public Member Functions

static void setFlag (std::atomic< bool > *flag)
 Set cancellation flag for current thread.
 
static std::atomic< bool > * getFlag ()
 Get current thread's cancellation flag.
 
static void clear ()
 Clear current thread's cancellation flag.
 
static bool shouldCancel ()
 Check if current thread should cancel (convenience method)
 

Detailed Description

Global search cancellation context using thread-local storage.

This class provides a mechanism to cancel long-running searches from external code. It uses thread-local storage to ensure thread safety and isolation.

Usage:

  1. Before search: SearchCancellation::setFlag(&cancelFlag)
  2. During search: SearchCancellation::shouldCancel() checks the flag
  3. After search: SearchCancellation::clear() cleans up

Thread-safety: Each thread has its own independent cancellation flag.

Member Function Documentation

◆ clear()

static void Lucene::SearchCancellation::clear ( )
static

Clear current thread's cancellation flag.

◆ getFlag()

static std::atomic< bool > * Lucene::SearchCancellation::getFlag ( )
static

Get current thread's cancellation flag.

Returns
Pointer to cancellation flag, or nullptr if not set

◆ setFlag()

static void Lucene::SearchCancellation::setFlag ( std::atomic< bool > *  flag)
static

Set cancellation flag for current thread.

Parameters
flagPointer to atomic boolean cancellation flag

◆ shouldCancel()

static bool Lucene::SearchCancellation::shouldCancel ( )
static

Check if current thread should cancel (convenience method)

Returns
true if should cancel, false otherwise

This method is called frequently in tight loops (e.g., ExactPhraseScorer::phraseFreq), so it uses memory_order_relaxed for minimal performance impact.


The documentation for this class was generated from the following file:

clucene.sourceforge.net