nudsfml.system.thread

Threads provide a way to run multiple parts of the code in parallel. When you launch a new thread, the execution is split and both the new thread and the caller run in parallel.

To use a $(U Thread), you construct it directly with the function to execute as the entry point of the thread. $(U Thread) has multiple template constructors, which means that you can use several types of entry points:

  • functions with no arguments
  • delegates with no arguments

$(PARA The thread ends when its function is terminated. If the owner $(U Thread) instance is destroyed before the thread is finished, the destructor will wait (see `wait()`).)

Members

Classes

Thread
class Thread

Utility class to manipulate threads.

Examples

// example 1: function
void threadFunc()
{
  ...
}

auto thread = new Thread(&threadFunc);
thread.launch();

// example 2: delegate
class Task
{
   void run()
   {
      ...
   }
}

auto task = new Task();
auto thread = new Thread(&task.run);
thread.launch();

Meta