LibreOffice Module vcl (master) 1
Classes | Macros
runinmain.hxx File Reference
#include <unordered_map>
#include <Block.h>
#include <osl/thread.h>
#include "saltimer.h"
#include <salframe.hxx>
#include <tools/debug.hxx>
Include dependency graph for runinmain.hxx:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

union  RuninmainResult
 Runs a command in the main thread. More...
 

Macros

#define OSX_RUNINMAIN_MEMBERS
 
#define OSX_RUNINMAIN(instance, command)
 
#define OSX_RUNINMAIN_POINTER(instance, command, type)
 
#define OSX_RUNINMAIN_UNION(instance, command, member)
 
#define OSX_INST_RUNINMAIN(command)    OSX_RUNINMAIN( this, command )
 convenience macros used from SalInstance More...
 
#define OSX_INST_RUNINMAIN_POINTER(command, type)    OSX_RUNINMAIN_POINTER( this, command, type )
 
#define OSX_INST_RUNINMAIN_UNION(command, member)    OSX_RUNINMAIN_UNION( this, command, member )
 
#define OSX_SALDATA_RUNINMAIN(command)    OSX_RUNINMAIN( GetSalData()->mpInstance, command )
 convenience macros using global SalData More...
 
#define OSX_SALDATA_RUNINMAIN_POINTER(command, type)    OSX_RUNINMAIN_POINTER( GetSalData()->mpInstance, command, type )
 
#define OSX_SALDATA_RUNINMAIN_UNION(command, member)    OSX_RUNINMAIN_UNION( GetSalData()->mpInstance, command, member )
 

Macro Definition Documentation

◆ OSX_INST_RUNINMAIN

#define OSX_INST_RUNINMAIN (   command)     OSX_RUNINMAIN( this, command )

convenience macros used from SalInstance

Definition at line 151 of file runinmain.hxx.

◆ OSX_INST_RUNINMAIN_POINTER

#define OSX_INST_RUNINMAIN_POINTER (   command,
  type 
)     OSX_RUNINMAIN_POINTER( this, command, type )

Definition at line 154 of file runinmain.hxx.

◆ OSX_INST_RUNINMAIN_UNION

#define OSX_INST_RUNINMAIN_UNION (   command,
  member 
)     OSX_RUNINMAIN_UNION( this, command, member )

Definition at line 157 of file runinmain.hxx.

◆ OSX_RUNINMAIN

#define OSX_RUNINMAIN (   instance,
  command 
)
Value:
if ( !instance->IsMainThread() ) \
{ \
DBG_TESTSOLARMUTEX(); \
SalYieldMutex *aMutex = static_cast<SalYieldMutex*>(instance->GetYieldMutex()); \
{ \
std::scoped_lock<std::mutex> g(aMutex->m_runInMainMutex); \
assert( !aMutex->m_aCodeBlock ); \
aMutex->m_aCodeBlock = Block_copy(^{ \
command; \
}); \
aMutex->m_wakeUpMain = true; \
aMutex->m_aInMainCondition.notify_all(); \
} \
dispatch_async(dispatch_get_main_queue(),^{ \
ImplNSAppPostEvent( AquaSalInstance::YieldWakeupEvent, NO ); \
}); \
{ \
std::unique_lock<std::mutex> g(aMutex->m_runInMainMutex); \
aMutex->m_aResultCondition.wait( \
g, [&aMutex]() { return aMutex->m_resultReady; }); \
aMutex->m_resultReady = false; \
} \
return; \
}
static const short YieldWakeupEvent
Definition: osx/salinst.h:158
std::mutex aMutex

Definition at line 69 of file runinmain.hxx.

◆ OSX_RUNINMAIN_MEMBERS

#define OSX_RUNINMAIN_MEMBERS
Value:
std::mutex m_runInMainMutex; \
std::condition_variable m_aInMainCondition; \
std::condition_variable m_aResultCondition; \
bool m_wakeUpMain = false; \
bool m_resultReady = false; \
RuninmainBlock m_aCodeBlock; \
RuninmainResult m_aResult;
Any m_aResult

Definition at line 60 of file runinmain.hxx.

◆ OSX_RUNINMAIN_POINTER

#define OSX_RUNINMAIN_POINTER (   instance,
  command,
  type 
)
Value:
if ( !instance->IsMainThread() ) \
{ \
DBG_TESTSOLARMUTEX(); \
SalYieldMutex *aMutex = static_cast<SalYieldMutex*>(instance->GetYieldMutex()); \
{ \
std::scoped_lock<std::mutex> g(aMutex->m_runInMainMutex); \
assert( !aMutex->m_aCodeBlock ); \
aMutex->m_aCodeBlock = Block_copy(^{ \
aMutex->m_aResult.pointer = static_cast<void*>( command ); \
}); \
aMutex->m_wakeUpMain = true; \
aMutex->m_aInMainCondition.notify_all(); \
} \
dispatch_async(dispatch_get_main_queue(),^{ \
ImplNSAppPostEvent( AquaSalInstance::YieldWakeupEvent, NO ); \
}); \
{ \
std::unique_lock<std::mutex> g(aMutex->m_runInMainMutex); \
aMutex->m_aResultCondition.wait( \
g, [&aMutex]() { return aMutex->m_resultReady; }); \
aMutex->m_resultReady = false; \
} \
return static_cast<type>( aMutex->m_aResult.pointer ); \
}
ResultType type

Definition at line 95 of file runinmain.hxx.

◆ OSX_RUNINMAIN_UNION

#define OSX_RUNINMAIN_UNION (   instance,
  command,
  member 
)
Value:
if ( !instance->IsMainThread() ) \
{ \
DBG_TESTSOLARMUTEX(); \
SalYieldMutex *aMutex = static_cast<SalYieldMutex*>(instance->GetYieldMutex()); \
{ \
std::scoped_lock<std::mutex> g(aMutex->m_runInMainMutex); \
assert( !aMutex->m_aCodeBlock ); \
aMutex->m_aCodeBlock = Block_copy(^{ \
aMutex->m_aResult.member = command; \
}); \
aMutex->m_wakeUpMain = true; \
aMutex->m_aInMainCondition.notify_all(); \
} \
dispatch_async(dispatch_get_main_queue(),^{ \
ImplNSAppPostEvent( AquaSalInstance::YieldWakeupEvent, NO ); \
}); \
{ \
std::unique_lock<std::mutex> g(aMutex->m_runInMainMutex); \
aMutex->m_aResultCondition.wait( \
g, [&aMutex]() { return aMutex->m_resultReady; }); \
aMutex->m_resultReady = false; \
} \
return std::move( aMutex->m_aResult.member ); \
}

Definition at line 121 of file runinmain.hxx.

◆ OSX_SALDATA_RUNINMAIN

#define OSX_SALDATA_RUNINMAIN (   command)     OSX_RUNINMAIN( GetSalData()->mpInstance, command )

convenience macros using global SalData

Definition at line 164 of file runinmain.hxx.

◆ OSX_SALDATA_RUNINMAIN_POINTER

#define OSX_SALDATA_RUNINMAIN_POINTER (   command,
  type 
)     OSX_RUNINMAIN_POINTER( GetSalData()->mpInstance, command, type )

Definition at line 167 of file runinmain.hxx.

◆ OSX_SALDATA_RUNINMAIN_UNION

#define OSX_SALDATA_RUNINMAIN_UNION (   command,
  member 
)     OSX_RUNINMAIN_UNION( GetSalData()->mpInstance, command, member )

Definition at line 170 of file runinmain.hxx.