Geogram  Version 1.9.1
A programming library of geometric algorithms
GEO::Process Namespace Reference

Abstraction layer for process management and multi-threading. More...

Classes

class  BasicSpinLockArray
 An array of light-weight synchronisation primitives (spinlocks). More...
 
class  CompactSpinLockArray
 An array of light-weight synchronisation primitives (spinlocks). More...
 

Typedefs

typedef std::atomic_flag spinlock
 A lightweight synchronization structure. More...
 
typedef CompactSpinLockArray SpinLockArray
 

Functions

void initialize (int flags)
 Initializes GeogramLib. More...
 
void terminate ()
 Terminates GeogramLib. More...
 
void sleep (index_t microseconds)
 Sleeps for a period of time. More...
 
void show_stats ()
 Displays statistics about the current process. More...
 
void brute_force_kill ()
 Terminates the current process.
 
index_t maximum_concurrent_threads ()
 Returns the maximum number of threads that can be running simultaneously. More...
 
void run_threads (ThreadGroup &threads)
 Runs a set of threads simultaneously. More...
 
index_t number_of_cores ()
 Gets the number of available cores. More...
 
void set_thread_manager (ThreadManager *thread_manager)
 Sets the thread manager (internal use). More...
 
bool is_running_threads ()
 Checks whether threads are running. More...
 
void enable_FPE (bool flag)
 Enables/disables floating point exceptions. More...
 
bool FPE_enabled ()
 Gets the status of floating point exceptions. More...
 
void enable_multithreading (bool flag)
 Enables/disables multi-threaded computations Multi-threading can also be configured by setting the value of the property "sys:multithread" with Environment::set_value(). More...
 
bool multithreading_enabled ()
 Gets the status of multi-threading. More...
 
void set_max_threads (index_t num_threads)
 Limits the number of concurrent threads to use. More...
 
index_t max_threads ()
 Gets the number of allowed concurrent threads. More...
 
void enable_cancel (bool flag)
 Enables interruption of cancelable tasks. More...
 
bool cancel_enabled ()
 Gets the status of the cancel mode. More...
 
size_t used_memory ()
 Gets the currently used memory. More...
 
size_t max_used_memory ()
 Gets the maximum used memory. More...
 
std::string executable_filename ()
 Gets the full path to the currently running program.
 
void print_stack_trace ()
 Prints a stack trace to the standard error.
 
bool os_init_threads ()
 
index_t os_number_of_cores ()
 
size_t os_used_memory ()
 
size_t os_max_used_memory ()
 
bool os_enable_FPE (bool flag)
 
bool os_enable_cancel (bool flag)
 
void os_install_signal_handlers ()
 
std::string os_executable_filename ()
 
void os_brute_force_kill ()
 
void os_print_stack_trace ()
 
void acquire_spinlock (volatile spinlock &x)
 Loops until x is available then reserves it. More...
 
void release_spinlock (volatile spinlock &x)
 Makes x available to other threads. More...
 

Detailed Description

Abstraction layer for process management and multi-threading.

Typedef Documentation

◆ spinlock

typedef std::atomic_flag GEO::Process::spinlock

A lightweight synchronization structure.

See

Definition at line 149 of file thread_sync.h.

Function Documentation

◆ acquire_spinlock()

void GEO::Process::acquire_spinlock ( volatile spinlock x)
inline

Loops until x is available then reserves it.

Parameters
[in]xa spinlock

Definition at line 155 of file thread_sync.h.

◆ cancel_enabled()

bool GEO::Process::cancel_enabled ( )

Gets the status of the cancel mode.

Return values
trueif the cancel mode is enabled
falseotherwise
See also
enable_cancel()

◆ enable_cancel()

void GEO::Process::enable_cancel ( bool  flag)

Enables interruption of cancelable tasks.

This allows to interrupt cancelable tasks by typing CTRL-C in the terminal. This sets a specific handler on the interrupt signal that calls Progress::cancel() is there is a running cancelable task. If no task is running, the program is interrupted. The cancel mode can also be configured by setting the value of the property "sys:cancel" with Environment::set_value().

Parameters
[in]flagset to true to enable cancel mode, false to disable.
See also
cancel_enabled()

◆ enable_FPE()

void GEO::Process::enable_FPE ( bool  flag)

Enables/disables floating point exceptions.

If FPEs are enabled, then floating point exceptions raise a SIGFPE signal, otherwise they generate NaNs. FPEs can also be configured by setting the value of the property "sys:FPE" with Environment::set_value().

Parameters
[in]flagset to true to enable FPEs, false to disable.
See also
FPE_enabled()

◆ enable_multithreading()

void GEO::Process::enable_multithreading ( bool  flag)

Enables/disables multi-threaded computations Multi-threading can also be configured by setting the value of the property "sys:multithread" with Environment::set_value().

Parameters
[in]flagset to true to enable multi-threading, false to disable.
See also
multithreading_enabled()

◆ FPE_enabled()

bool GEO::Process::FPE_enabled ( )

Gets the status of floating point exceptions.

Return values
trueif FPE are enabled
falseotherwise
See also
enable_FPE()

◆ initialize()

void GEO::Process::initialize ( int  flags)

Initializes GeogramLib.

Parameters
[in]flagsthe flags passed to GEO::initialize()

This function must be called once before using any functionality of GeogramLib.

◆ is_running_threads()

bool GEO::Process::is_running_threads ( )

Checks whether threads are running.

Return values
trueif concurrent threads are currently running as an effect to Process::run_threads().
falseotherwise.
See also
Process::run_threads()

◆ max_threads()

index_t GEO::Process::max_threads ( )

Gets the number of allowed concurrent threads.

See also
set_max_threads()

◆ max_used_memory()

size_t GEO::Process::max_used_memory ( )

Gets the maximum used memory.

Returns
the maximum used memory in bytes

◆ maximum_concurrent_threads()

index_t GEO::Process::maximum_concurrent_threads ( )

Returns the maximum number of threads that can be running simultaneously.

Return values
Thenumber of cores if multi-threading is supported
1otherwise.

◆ multithreading_enabled()

bool GEO::Process::multithreading_enabled ( )

Gets the status of multi-threading.

Return values
trueif multi-threading is enabled
falseotherwise
See also
enable_multithreading()

◆ number_of_cores()

index_t GEO::Process::number_of_cores ( )

Gets the number of available cores.

Returns
The number of available cores including the "virtual ones" if hyper-threading is activated.

◆ release_spinlock()

void GEO::Process::release_spinlock ( volatile spinlock x)
inline

Makes x available to other threads.

Parameters
[in]xa spinlock

Definition at line 173 of file thread_sync.h.

◆ run_threads()

void GEO::Process::run_threads ( ThreadGroup threads)

Runs a set of threads simultaneously.

Launches the execution of the threads contained in the vector threads and waits for the completion of all of them.

◆ set_max_threads()

void GEO::Process::set_max_threads ( index_t  num_threads)

Limits the number of concurrent threads to use.

The number of threads can also be configured by setting the value of the property "sys:max_threads" with Environment::set_value().

Parameters
[in]num_threadsmaximum number of threads to use.
See also
max_threads()

◆ set_thread_manager()

void GEO::Process::set_thread_manager ( ThreadManager thread_manager)

Sets the thread manager (internal use).

This sets the ThreadManager to use for concurrent thread execution. This function is called internally by Process::initialize() and should not be called explicitly.

Note
For internal use only

◆ show_stats()

void GEO::Process::show_stats ( )

Displays statistics about the current process.

Displays the maximum used amount of memory.

◆ sleep()

void GEO::Process::sleep ( index_t  microseconds)

Sleeps for a period of time.

Parameters
[in]microsecondsthe time to sleep, in microseconds.

◆ terminate()

void GEO::Process::terminate ( )

Terminates GeogramLib.

This function is called automatically when the program exits, so it should never be called directly.

◆ used_memory()

size_t GEO::Process::used_memory ( )

Gets the currently used memory.

Returns
the used memory in bytes