40 #ifndef GEOGRAM_BASIC_PROCESS
41 #define GEOGRAM_BASIC_PROCESS
78 virtual void run() = 0;
108 return current() ==
nullptr ? 0 : current()->id();
135 static void set_current(
Thread* thread);
164 template <
class THREAD>
183 Thread* result = ThreadGroup::operator[] (i);
184 return static_cast<THREAD*
>(result);
282 Thread::set_current(thread);
530 bool interleaved =
false
571 std::function<
void()> f1,
572 std::function<
void()> f2
582 std::function<
void()> f1,
583 std::function<
void()> f2,
584 std::function<
void()> f3,
585 std::function<
void()> f4
596 std::function<
void()> f1,
597 std::function<
void()> f2,
598 std::function<
void()> f3,
599 std::function<
void()> f4,
600 std::function<
void()> f5,
601 std::function<
void()> f6,
602 std::function<
void()> f7,
603 std::function<
void()> f8
#define geo_debug_assert(x)
Verifies that a condition is met.
Base class for reference-counted objects.
Single thread ThreadManager.
~MonoThreadingThreadManager() override
index_t maximum_concurrent_threads() override
Gets the maximum number of possible concurrent threads.
void run_concurrent_threads(ThreadGroup &threads, index_t max_threads) override
Runs a group of Threads concurrently.
A smart pointer with reference-counted copy semantics.
Platform-independent base class for running concurrent threads.
virtual void run_concurrent_threads(ThreadGroup &threads, index_t max_threads)=0
Runs a group of Threads concurrently.
static void set_current_thread(Thread *thread)
Specifies the current instance, used by current().
~ThreadManager() override
virtual void run_threads(ThreadGroup &threads)
Runs a group of Threads.
virtual index_t maximum_concurrent_threads()=0
Gets the maximum number of possible concurrent threads.
static void set_thread_id(Thread *thread, index_t id)
Sets the id of a thread.
Platform-independent base class for running threads.
static index_t current_id()
Gets the identifier of the current thread.
index_t id() const
Gets the identifier of this thread.
virtual void run()=0
Starts the thread execution.
Thread()
Thread constructor.
static Thread * current()
Gets the current thread.
Typed collection of Threads.
THREAD * operator[](index_t i)
Gets a thread element by index.
TypedThreadGroup()
Creates an empty group of Threads.
Base class of reference-counted objects, to be used with smart pointers.
Common include file, providing basic definitions. Should be included before anything else by all head...
void run_threads(ThreadGroup &threads)
Runs a set of threads simultaneously.
void enable_cancel(bool flag)
Enables interruption of cancelable tasks.
void initialize(int flags)
Initializes GeogramLib.
void set_thread_manager(ThreadManager *thread_manager)
Sets the thread manager (internal use).
std::string executable_filename()
Gets the full path to the currently running program.
void set_max_threads(index_t num_threads)
Limits the number of concurrent threads to use.
void sleep(index_t microseconds)
Sleeps for a period of time.
void brute_force_kill()
Terminates the current process.
index_t maximum_concurrent_threads()
Returns the maximum number of threads that can be running simultaneously.
void enable_FPE(bool flag)
Enables/disables floating point exceptions.
bool multithreading_enabled()
Gets the status of multi-threading.
index_t number_of_cores()
Gets the number of available cores.
void print_stack_trace()
Prints a stack trace to the standard error.
bool FPE_enabled()
Gets the status of floating point exceptions.
bool is_running_threads()
Checks whether threads are running.
size_t max_used_memory()
Gets the maximum used memory.
size_t used_memory()
Gets the currently used memory.
bool cancel_enabled()
Gets the status of the cancel mode.
void enable_multithreading(bool flag)
Enables/disables multi-threaded computations Multi-threading can also be configured by setting the va...
void terminate()
Terminates GeogramLib.
index_t max_threads()
Gets the number of allowed concurrent threads.
void show_stats()
Displays statistics about the current process.
Global Vorpaline namespace.
void parallel(std::function< void()> f1, std::function< void()> f2)
Calls functions in parallel.
std::vector< Thread_var > ThreadGroup
Collection of Threads.
SmartPointer< Thread > Thread_var
void parallel_for_slice(index_t from, index_t to, std::function< void(index_t, index_t)> func, index_t threads_per_core=1)
Executes a loop with concurrent threads.
void parallel_for(index_t from, index_t to, std::function< void(index_t)> func, index_t threads_per_core=1, bool interleaved=false)
Executes a loop with concurrent threads.
geo_index_t index_t
The type for storing and manipulating indices.
SmartPointer< ThreadManager > ThreadManager_var
Pointers with automatic reference counting.
Functions and classes for process manipulation.