Proxy classes provide thread-safe interface to global objects.
For example: TGWin32VirtualXProxy (to gVirtualX).
Proxy object creates callback object and posts a windows message to "processing thread". When windows message is received callback ("real method") is executed.
For example: gVirtualX->ClearWindow()
Howto create proxy class:
Naming. name of proxy = TGWin32 + the name of "virtual base class" + Proxy
e.g. TGWin32VirtualXProxy = TGWin32 + VirtualX + Proxy
Class definition. proxy class must be inherited from "virtual base class" and TGWin32ProxyBase class. For example:
class TGWin32VirtualX : public TVirtualX , public TGWin32ProxyBase
Constructors, destructor, extra methods.
For example: static TVirtualX *RealObject(); static TVirtualX *ProxyObject();
the names of other macros say about itself.
For example: VOID_METHOD_ARG0(VirtualX,SetFillAttributes,1) void TGWin32VirtualXProxy::SetFillAttributes()
RETURN_METHOD_ARG0_CONST(VirtualX,Visual_t,GetVisual) Visual_t TGWin32VirtualXProxy::GetVisual() const
RETURN_METHOD_ARG2(VirtualX,Int_t,OpenPixmap,UInt_t,w,UInt_t,h) Int_t TGWin32VirtualXProxy::OpenPixmap,UInt_t w,UInt_t h)
Definition at line 22 of file TGWin32ProxyBase.h.
Public Member Functions | |
TGWin32ProxyBase () | |
ctor More... | |
virtual | ~TGWin32ProxyBase () |
dtor More... | |
virtual void | ExecuteCallBack (Bool_t sync) |
Executes all batched callbacks and the latest callback This method is executed by server thread. More... | |
ULong_t | GetId () const |
virtual Double_t | GetMilliSeconds () |
returns elapsed time in milliseconds with microseconds precision More... | |
Static Public Member Functions | |
static void | GlobalLock () |
lock any proxy (client thread) More... | |
static void | GlobalUnlock () |
unlock any proxy (client thread) More... | |
static Bool_t | IsGloballyLocked () |
Check the status of the lock. More... | |
static void | Lock () |
enter critical section More... | |
static Bool_t | Ping () |
send ping messsage to server thread More... | |
static void | Unlock () |
leave critical section More... | |
Static Public Attributes | |
static ULong_t | fgMainThreadId = 0 |
main thread ID More... | |
static ULong_t | fgPingMessageId = 0 |
ping message ID More... | |
static ULong_t | fgPostMessageId = 0 |
post message ID More... | |
static ULong_t | fgUserThreadId = 0 |
user (e.g. python) thread ID More... | |
Protected Member Functions | |
virtual Bool_t | ForwardCallBack (Bool_t sync) |
if sync is kTRUE: More... | |
virtual void | SendExitMessage () |
send exit message to server thread More... | |
Protected Attributes | |
Int_t | fBatchLimit |
batch limit More... | |
TGWin32CallBack | fCallBack |
callback function (executed by "main" thread) More... | |
ULong_t | fId |
thread id. There is one proxy per client thread More... | |
Bool_t | fIsVirtualX |
true if actual TVirtualX implementation More... | |
TList * | fListOfCallBacks |
list of callbacks (used for batch processing) More... | |
void * | fParam |
arguments passed to/from callback function More... | |
TGWin32ProxyBasePrivate * | fPimpl |
very private data More... | |
Static Protected Attributes | |
static Long_t | fgLock = 0 |
fgLock=1 - all client threads locked More... | |
static UInt_t | fMaxResponseTime = 0 |
max period for waiting response from server thread More... | |
Friends | |
class | TGWin32 |
class | TGWin32GL |
#include <TGWin32ProxyBase.h>
TGWin32ProxyBase::TGWin32ProxyBase | ( | ) |
ctor
Definition at line 136 of file TGWin32ProxyBase.cxx.
|
virtual |
dtor
Definition at line 153 of file TGWin32ProxyBase.cxx.
Executes all batched callbacks and the latest callback This method is executed by server thread.
Definition at line 235 of file TGWin32ProxyBase.cxx.
if sync is kTRUE:
returns kTRUE if callback execution is delayed (batched)
Definition at line 262 of file TGWin32ProxyBase.cxx.
|
inline |
Definition at line 58 of file TGWin32ProxyBase.h.
|
virtual |
returns elapsed time in milliseconds with microseconds precision
Definition at line 207 of file TGWin32ProxyBase.cxx.
|
static |
lock any proxy (client thread)
Definition at line 181 of file TGWin32ProxyBase.cxx.
|
static |
unlock any proxy (client thread)
Definition at line 190 of file TGWin32ProxyBase.cxx.
|
static |
Check the status of the lock.
Definition at line 327 of file TGWin32ProxyBase.cxx.
|
static |
enter critical section
Definition at line 165 of file TGWin32ProxyBase.cxx.
|
static |
send ping messsage to server thread
Definition at line 199 of file TGWin32ProxyBase.cxx.
|
protectedvirtual |
send exit message to server thread
Definition at line 335 of file TGWin32ProxyBase.cxx.
|
static |
leave critical section
Definition at line 173 of file TGWin32ProxyBase.cxx.
|
friend |
Definition at line 23 of file TGWin32ProxyBase.h.
|
friend |
Definition at line 24 of file TGWin32ProxyBase.h.
|
protected |
batch limit
Definition at line 28 of file TGWin32ProxyBase.h.
|
protected |
callback function (executed by "main" thread)
Definition at line 30 of file TGWin32ProxyBase.h.
|
staticprotected |
fgLock=1 - all client threads locked
Definition at line 35 of file TGWin32ProxyBase.h.
|
static |
main thread ID
Definition at line 43 of file TGWin32ProxyBase.h.
|
static |
ping message ID
Definition at line 42 of file TGWin32ProxyBase.h.
|
static |
post message ID
Definition at line 41 of file TGWin32ProxyBase.h.
|
static |
user (e.g. python) thread ID
Definition at line 44 of file TGWin32ProxyBase.h.
|
protected |
thread id. There is one proxy per client thread
Definition at line 32 of file TGWin32ProxyBase.h.
|
protected |
true if actual TVirtualX implementation
Definition at line 33 of file TGWin32ProxyBase.h.
|
protected |
list of callbacks (used for batch processing)
Definition at line 29 of file TGWin32ProxyBase.h.
|
staticprotected |
max period for waiting response from server thread
Definition at line 34 of file TGWin32ProxyBase.h.
|
protected |
arguments passed to/from callback function
Definition at line 31 of file TGWin32ProxyBase.h.
|
protected |
very private data
Definition at line 27 of file TGWin32ProxyBase.h.