Browse Source

Mention thread-safety on Application class

Signed-off-by: falkTX <falktx@falktx.com>
pull/297/head
falkTX 4 years ago
parent
commit
1ccefd8c72
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
2 changed files with 6 additions and 2 deletions
  1. +4
    -0
      dgl/Application.hpp
  2. +2
    -2
      dgl/src/ApplicationPrivateData.cpp

+ 4
- 0
dgl/Application.hpp View File

@@ -30,6 +30,8 @@ START_NAMESPACE_DGL
There's no single/global application instance in DGL, and multiple windows can share the same app instance. There's no single/global application instance in DGL, and multiple windows can share the same app instance.


In standalone mode an application will automatically quit its event-loop when all its windows are closed. In standalone mode an application will automatically quit its event-loop when all its windows are closed.

Unless stated otherwise, functions within this class are not thread-safe.
*/ */
class Application class Application
{ {
@@ -61,6 +63,7 @@ public:
/** /**
Quit the application. Quit the application.
This stops the event-loop and closes all Windows. This stops the event-loop and closes all Windows.
This function is thread-safe.
@note This function is meant for standalones only, *never* call this from plugins. @note This function is meant for standalones only, *never* call this from plugins.
*/ */
void quit(); void quit();
@@ -68,6 +71,7 @@ public:
/** /**
Check if the application is about to quit. Check if the application is about to quit.
Returning true means there's no event-loop running at the moment (or it's just about to stop). Returning true means there's no event-loop running at the moment (or it's just about to stop).
This function is thread-safe.
*/ */
bool isQuiting() const noexcept; bool isQuiting() const noexcept;




+ 2
- 2
dgl/src/ApplicationPrivateData.cpp View File

@@ -34,7 +34,7 @@ static ThreadHandle getCurrentThreadHandle() noexcept
#endif #endif
} }


static bool isThisMainThread(const ThreadHandle mainThreadHandle) noexcept
static bool isThisTheMainThread(const ThreadHandle mainThreadHandle) noexcept
{ {
#ifdef DISTRHO_OS_WINDOWS #ifdef DISTRHO_OS_WINDOWS
return GetCurrentThread() == mainThreadHandle; // IsGUIThread ? return GetCurrentThread() == mainThreadHandle; // IsGUIThread ?
@@ -127,7 +127,7 @@ void Application::PrivateData::quit()
{ {
DISTRHO_SAFE_ASSERT_RETURN(isStandalone,); DISTRHO_SAFE_ASSERT_RETURN(isStandalone,);


if (! isThisMainThread(mainThreadHandle))
if (! isThisTheMainThread(mainThreadHandle))
{ {
if (! isQuittingInNextCycle) if (! isQuittingInNextCycle)
{ {


Loading…
Cancel
Save