Skip to main content
The restrictions were for multiple write only threads. revised for single write.
Source Link
agone
  • 522
  • 3
  • 8

A single valued integer of machine word size(32 or 64 bits) is guaranteed to provide consistent atomic reads and writes across threads, but not both within the sameone read-only thread and a single read-write thread, as in increment or += any operator=...

In other words only assign constant values or "write thread" local variables, like a thread completion percentage.


Define an int or long(see above), or your favorite alias, status variable for each thread and an array of strings to draw.

The string array will help with language translations later on.

Either, if each thread status variable and draw the string from the array.

Or, draw the base text for each of the string values and append the completion values.

This way:

  • No synthetic or synchronizing delays,i.e. mutexes, are needed
  • The string draw order is maintained and nothing completed gets skipped
  • More frequent progress indicators will be shown on slower computers (thread completion percentage).

As a side note setting the optimization level above -O2 is usually overkill and may even lead to decreased run-time performance.

A single valued integer of machine word size(32 or 64 bits) is guaranteed to provide consistent atomic reads and writes across threads, but not both within the same thread, as in increment or += any operator=...

In other words only assign constant values or "write thread" local variables, like a thread completion percentage.


Define an int or long(see above), or your favorite alias, status variable for each thread and an array of strings to draw.

The string array will help with language translations later on.

Either, if each thread status variable and draw the string from the array.

Or, draw the base text for each of the string values and append the completion values.

This way:

  • No synthetic or synchronizing delays,i.e. mutexes, are needed
  • The string draw order is maintained and nothing completed gets skipped
  • More frequent progress indicators will be shown on slower computers (thread completion percentage).

As a side note setting the optimization level above -O2 is usually overkill and may even lead to decreased run-time performance.

A single valued integer of machine word size(32 or 64 bits) is guaranteed to provide consistent atomic reads and writes across one read-only thread and a single read-write thread.


Define an int or long(see above), or your favorite alias, status variable for each thread and an array of strings to draw.

The string array will help with language translations later on.

Either, if each thread status variable and draw the string from the array.

Or, draw the base text for each of the string values and append the completion values.

This way:

  • No synthetic or synchronizing delays,i.e. mutexes, are needed
  • The string draw order is maintained and nothing completed gets skipped
  • More frequent progress indicators will be shown on slower computers (thread completion percentage).

As a side note setting the optimization level above -O2 is usually overkill and may even lead to decreased run-time performance.

Source Link
agone
  • 522
  • 3
  • 8

A single valued integer of machine word size(32 or 64 bits) is guaranteed to provide consistent atomic reads and writes across threads, but not both within the same thread, as in increment or += any operator=...

In other words only assign constant values or "write thread" local variables, like a thread completion percentage.


Define an int or long(see above), or your favorite alias, status variable for each thread and an array of strings to draw.

The string array will help with language translations later on.

Either, if each thread status variable and draw the string from the array.

Or, draw the base text for each of the string values and append the completion values.

This way:

  • No synthetic or synchronizing delays,i.e. mutexes, are needed
  • The string draw order is maintained and nothing completed gets skipped
  • More frequent progress indicators will be shown on slower computers (thread completion percentage).

As a side note setting the optimization level above -O2 is usually overkill and may even lead to decreased run-time performance.