forked from boostorg/thread
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlambda_pass.cpp
More file actions
89 lines (77 loc) · 1.82 KB
/
Copy pathlambda_pass.cpp
File metadata and controls
89 lines (77 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// Copyright (C) 2011 Vicente J. Botet Escriba
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// <boost/thread/thread.hpp>
// class thread
// template <class Clousure> thread(Clousure f);
#include <new>
#include <cstdlib>
#include <cassert>
#include <boost/thread/thread_only.hpp>
#include <boost/detail/lightweight_test.hpp>
#if ! defined BOOST_NO_CXX11_LAMBDAS
unsigned throw_one = 0xFFFF;
#if defined _GLIBCXX_THROW
void* operator new(std::size_t s) _GLIBCXX_THROW (std::bad_alloc)
#elif defined BOOST_MSVC
void* operator new(std::size_t s)
#elif __cplusplus > 201402L
void* operator new(std::size_t s)
#else
void* operator new(std::size_t s) throw (std::bad_alloc)
#endif
{
if (throw_one == 0) throw std::bad_alloc();
--throw_one;
return std::malloc(s);
}
#if defined BOOST_MSVC
void operator delete(void* p)
#else
void operator delete(void* p) BOOST_NOEXCEPT_OR_NOTHROW
#endif
{
std::free(p);
}
bool f_run = false;
int main()
{
{
f_run = false;
boost::thread t( []() { f_run = true; } );
t.join();
BOOST_TEST(f_run == true);
}
#ifndef BOOST_MSVC
{
f_run = false;
try
{
throw_one = 0;
boost::thread t( []() { f_run = true; } );
BOOST_TEST(false);
}
catch (...)
{
throw_one = 0xFFFF;
BOOST_TEST(!f_run);
}
}
#endif
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif