1 /**
2 * Module for cross threading exceptions.
3 *
4 * Authors:
5 *   Jacob Jensen
6 * License:
7 *   https://github.com/PoisonEngine/poison-ui/blob/master/LICENSE
8 */
9 module poison.core.exceptions.crossthreadingexception;
10 
11 import std.concurrency : Tid;
12 import std..string : format;
13 
14 /// Exception thrown when attempting cross threading access in thread-bound contexts.
15 class CrossThreadingExeption : Exception {
16   private:
17   /// The tid the thread was accessed from.
18   Tid _tid;
19 
20   public:
21   /**
22   * Creates a new instance of the cross threading exception.
23   * Params:
24   *   tid = The accessible tid.
25   *   msg = The message of the exception.
26   */
27   this(Tid tid, string msg) {
28     msg = format("Tid: %s\r\n%s", tid, msg);
29 
30     super(msg);
31 
32     _tid = tid;
33   }
34 
35   @property {
36     /// Gets the tid that the thread-bound context was accessed from.
37     Tid tid() { return _tid; }
38   }
39 }