| @@ -337,6 +337,10 @@ namespace juce | |||||
| #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && ! defined (JUCE_DELETED_FUNCTION) | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && ! defined (JUCE_DELETED_FUNCTION) | ||||
| #define JUCE_DELETED_FUNCTION = delete | #define JUCE_DELETED_FUNCTION = delete | ||||
| #endif | #endif | ||||
| #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && ! defined (JUCE_COMPILER_SUPPORTS_LAMBDAS) | |||||
| #define JUCE_COMPILER_SUPPORTS_LAMBDAS 1 | |||||
| #endif | |||||
| #endif | #endif | ||||
| #if JUCE_CLANG && defined (__has_feature) | #if JUCE_CLANG && defined (__has_feature) | ||||
| @@ -356,6 +360,10 @@ namespace juce | |||||
| #define JUCE_DELETED_FUNCTION = delete | #define JUCE_DELETED_FUNCTION = delete | ||||
| #endif | #endif | ||||
| #if __has_feature (cxx_lambdas) | |||||
| #define JUCE_COMPILER_SUPPORTS_LAMBDAS 1 | |||||
| #endif | |||||
| #ifndef JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL | #ifndef JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL | ||||
| #define JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL 1 | #define JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL 1 | ||||
| #endif | #endif | ||||
| @@ -372,6 +380,7 @@ namespace juce | |||||
| #if defined (_MSC_VER) && _MSC_VER >= 1700 | #if defined (_MSC_VER) && _MSC_VER >= 1700 | ||||
| #define JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL 1 | #define JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL 1 | ||||
| #define JUCE_COMPILER_SUPPORTS_LAMBDAS 1 | |||||
| #endif | #endif | ||||
| #ifndef JUCE_DELETED_FUNCTION | #ifndef JUCE_DELETED_FUNCTION | ||||
| @@ -131,6 +131,7 @@ void MessageManager::stopDispatchLoop() | |||||
| #endif | #endif | ||||
| //============================================================================== | //============================================================================== | ||||
| #if JUCE_COMPILER_SUPPORTS_LAMBDAS | |||||
| struct AsyncFunction : private MessageManager::MessageBase | struct AsyncFunction : private MessageManager::MessageBase | ||||
| { | { | ||||
| AsyncFunction (std::function<void(void)> f) : fn (f) { post(); } | AsyncFunction (std::function<void(void)> f) : fn (f) { post(); } | ||||
| @@ -146,7 +147,9 @@ void MessageManager::callAsync (std::function<void(void)> f) | |||||
| { | { | ||||
| new AsyncFunction (f); | new AsyncFunction (f); | ||||
| } | } | ||||
| #endif | |||||
| //============================================================================== | |||||
| class AsyncFunctionCallback : public MessageManager::MessageBase | class AsyncFunctionCallback : public MessageManager::MessageBase | ||||
| { | { | ||||
| public: | public: | ||||
| @@ -91,10 +91,12 @@ public: | |||||
| #endif | #endif | ||||
| //============================================================================== | //============================================================================== | ||||
| #if JUCE_COMPILER_SUPPORTS_LAMBDAS | |||||
| /** Asynchronously invokes a function or C++11 lambda on the message thread. | /** Asynchronously invokes a function or C++11 lambda on the message thread. | ||||
| Internally this uses the CallbackMessage class to invoke the callback. | Internally this uses the CallbackMessage class to invoke the callback. | ||||
| */ | */ | ||||
| static void callAsync (std::function<void(void)>); | static void callAsync (std::function<void(void)>); | ||||
| #endif | |||||
| /** Calls a function using the message-thread. | /** Calls a function using the message-thread. | ||||