Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
thread-wrapper-self-recognition-test.cpp
Go to the documentation of this file.
1/*
2 ThreadWrapperSelfRecognitionTest(Test) - detect when code is running within a thread
3
4 Copyright (C)
5 2017, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12* *****************************************************************/
13
19#include "lib/test/run.hpp"
20#include "lib/thread.hpp"
21
22using test::Test;
23
24
25
26namespace lib {
27namespace test {
28
29
30 /******************************************************/
38 {
39
40 virtual void
41 run (Arg)
42 {
43 ThreadJoinable<bool> testThread{"Thread self detection"
44 ,[&]{
45 return testThread.invokedWithinThread();
46 }};
47
48 CHECK (not testThread.invokedWithinThread());
49 CHECK (testThread.join().get<bool>());
50 }
51 };
52
53
54
57
58
59
60}} // namespace lib::test
Variant of the standard case, requiring to wait and join() on the termination of this thread.
Definition thread.hpp:670
Abstract Base Class for all testcases.
Definition run.hpp:54
Implementation namespace for support and library code.
Test runner and basic definitions for tests.
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
Definition run.hpp:116
Convenience front-end to simplify and codify basic thread handling.