OEThreadedDots

class OEThreadedDots

This class provides a threadsafe version of OEDots. Multiple threads can call OEThreadedDots.Update to update the progress in an efficient manner in a thread-safe way. This class will create an internal operating system thread to handle output to OEPlatform.oeerr. The complete progress is not guaranteed to be output to the terminal until OEThreadedDots.Total is called.

Warning

It is an error to call OEThreadedDots.Update after calling OEThreadedDots.Total. The object is essentially shut down and new one should be created.

Constructors

OEThreadedDots(unsigned int bigstep, unsigned int smallstep,
               const char *objectname="")

Controls how the following output gets updated:

.......... 10000 things processed.
.......... 20000 things processed.
.......... 30000 things processed.
.......... 40000 things processed.
.......... 50000 things processed.
.......... 60000 things processed.
.......... 70000 things processed.
.......... 80000 things processed.

bigstep

The number of elements before a new line is generated. The above example is a bigstep of 10000.

smallstep

The number of elements before a single new dot, ., is printed. The above example is a smallstep of 1000. Or 10 dots per line.

objectname

A description of what is being processed. In the above example, this is “things”.

Total

void Total()

Prints a final summary line like the following:

Total: 80000 things processed.

Note

Calling this method waits for all information to flush to the IO thread and then terminates and joins that thread. So this function is effectively a blocking call on those operations. But the operations are typically very cheap, so the blocking nature is not noticeable.

Update

void Update(unsigned int step=1)

Update the progress with the number of elements specified by step. The default is 1 element, but any number can be specified. However, 0 is not a valid step size and will throw an error.

Note

For OEThreadedDots, this method is thread-safe to call from multiple threads even though it is a non-const method.