Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Thread.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2010, The Barbarian Group
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without modification, are permitted provided that
6  the following conditions are met:
7 
8  * Redistributions of source code must retain the above copyright notice, this list of conditions and
9  the following disclaimer.
10  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
11  the following disclaimer in the documentation and/or other materials provided with the distribution.
12 
13  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
14  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
15  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
16  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
17  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
18  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
19  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
20  POSSIBILITY OF SUCH DAMAGE.
21 */
22 
23 #pragma once
24 
25 #include "cinder/Cinder.h"
26 #if defined( CINDER_COCOA )
28 #endif
29 #if defined( CINDER_MAC )
30  #include <objc/objc-auto.h>
31 #endif
32 
33 #if defined( CINDER_WINRT )
34  #include <thread>
35  #include <mutex>
36  #include <condition_variable>
37  #include <future>
38 
39 #elif (defined( _MSC_VER ) && ( _MSC_VER >= 1700 )) || defined( _LIBCPP_VERSION )
40  #include <thread>
41  #include <mutex>
42  #include <condition_variable>
43  #include <future>
44 #else
45  #include <boost/thread/mutex.hpp>
46  #include <boost/thread/recursive_mutex.hpp>
47  #include <boost/thread/thread.hpp>
48  #include <boost/thread/condition_variable.hpp>
49  #define BOOST_THREAD_PROVIDES_FUTURE
50  #include <boost/thread/future.hpp>
51 
52  // Promote classes from boost which will be part of std:: in C++1x where necessary
53  namespace std {
54  using boost::mutex;
55  using boost::recursive_mutex;
56  using boost::thread;
57  using boost::lock_guard;
58  using boost::unique_lock;
59  using boost::condition_variable;
60  namespace this_thread {
61  using boost::this_thread::yield;
62  using boost::this_thread::get_id;
63  }
64  using boost::future;
65  using boost::packaged_task;
66  using boost::promise;
67  }
68 #endif
69 
70 namespace cinder {
72 class ThreadSetup {
73  public:
75 #if defined( CINDER_MAC )
76  objc_registerThreadWithCollector();
77 #endif
78  }
79 
81  }
82 
83  protected:
84 #if defined( CINDER_COCOA )
85  cocoa::SafeNsAutoreleasePool mAutoreleasePool;
86 #endif
87 };
88 
89 } // namespace cinder
Represents an exception-safe NSAutoreleasePool. Replaces the global NSAutoreleasePool for its lifetim...
Definition: CinderCocoa.h:91
Create an instance of this class at the beginning of any multithreaded code that makes use of Cinder ...
Definition: Thread.h:72
~ThreadSetup()
Definition: Thread.h:80
ThreadSetup()
Definition: Thread.h:74