94 class TGWin32CallBackObject :
public TObject {
99 TGWin32CallBackObject(
TGWin32CallBack cb,
void *p):fCallBack(cb),fParam(p) {}
100 ~TGWin32CallBackObject() {
if (fParam)
delete fParam; }
104 class TGWin32ProxyBasePrivate {
107 TGWin32ProxyBasePrivate();
108 ~TGWin32ProxyBasePrivate();
114 TGWin32ProxyBasePrivate::TGWin32ProxyBasePrivate()
122 TGWin32ProxyBasePrivate::~TGWin32ProxyBasePrivate()
124 if (fEvent) ::CloseHandle(fEvent);
145 fListOfCallBacks =
new TList();
147 fId = ::GetCurrentThreadId();
148 fPimpl =
new TGWin32ProxyBasePrivate();
150 if (!fgPostMessageId) fgPostMessageId = ::RegisterWindowMessage(
"TGWin32ProxyBase::Post");
151 if (!fgPingMessageId) fgPingMessageId = ::RegisterWindowMessage(
"TGWin32ProxyBase::Ping");
159 fListOfCallBacks->Delete();
160 delete fListOfCallBacks;
161 fListOfCallBacks = 0;
187 if (IsGloballyLocked())
return;
188 ::InterlockedIncrement(&fgLock);
196 if (!IsGloballyLocked())
return;
197 ::InterlockedDecrement(&fgLock);
205 return ::PostThreadMessage(fgMainThreadId, fgPingMessageId, (WPARAM)0, 0
L);
213 static LARGE_INTEGER freq;
219 LARGE_INTEGER count0;
220 ::QueryPerformanceFrequency(&freq);
221 ::QueryPerformanceCounter(&count0);
224 dummy = ((
Double_t)count0.QuadPart - overhead)*1000./((
Double_t)freq.QuadPart);
226 ::QueryPerformanceCounter(&count);
231 ::QueryPerformanceCounter(&count);
232 return ((
Double_t)count.QuadPart - overhead)*1000./((
Double_t)freq.QuadPart);
242 if (fListOfCallBacks && fListOfCallBacks->GetSize()) {
243 TIter next(fListOfCallBacks);
244 TGWin32CallBackObject *obj;
246 while ((obj = (TGWin32CallBackObject*)next())) {
247 obj->fCallBack(obj->fParam);
251 if (fCallBack) fCallBack(fParam);
252 ::SetEvent(fPimpl->fEvent);
270 if (!fgMainThreadId)
return kFALSE;
272 while (IsGloballyLocked()) {
274 #ifdef OLD_THREAD_IMPLEMENTATION 275 if (GetCurrentThreadId() == fgMainThreadId)
279 if (!fgMainThreadId)
return kFALSE;
282 Bool_t batch = !sync && (fListOfCallBacks->GetSize() < fBatchLimit);
286 if (!fgUserThreadId && fIsVirtualX &&
287 (GetCurrentThreadId() != fgMainThreadId) &&
288 (fListOfCallBacks->GetSize() < fBatchLimit))
292 fListOfCallBacks->Add(
new TGWin32CallBackObject(fCallBack, fParam));
296 while (!::PostThreadMessage(fgMainThreadId, fgPostMessageId, (WPARAM)
this, 0
L)) {
299 if (wait++ > 5)
return kFALSE;
302 #ifdef OLD_THREAD_IMPLEMENTATION 306 DWORD res = WAIT_TIMEOUT;
307 while (res == WAIT_TIMEOUT) {
308 res = ::WaitForSingleObject(fPimpl->fEvent, 100);
309 #ifdef OLD_THREAD_IMPLEMENTATION 310 if ((GetCurrentThreadId() == fgMainThreadId) ||
311 (!
gROOT->IsLineProcessing() && IsGloballyLocked())) {
314 if (cnt++ > 20)
break;
317 ::ResetEvent(fPimpl->fEvent);
319 if (res == WAIT_TIMEOUT) {
324 fListOfCallBacks->Delete();
341 ::PostThreadMessage(fgMainThreadId, WM_QUIT, 0, 0
L);
virtual void ExecuteCallBack(Bool_t sync)
Executes all batched callbacks and the latest callback This method is executed by server thread...
static void GlobalUnlock()
unlock any proxy (client thread)
RooArgList L(const RooAbsArg &v1)
static UInt_t fMaxResponseTime
max period for waiting response from server thread
virtual ~TGWin32ProxyBase()
dtor
static void Lock()
enter critical section
virtual void SendExitMessage()
send exit message to server thread
static Long_t fgLock
fgLock=1 - all client threads locked
static void GlobalLock()
lock any proxy (client thread)
static ULong_t fgMainThreadId
main thread ID
static ULong_t fgPostMessageId
post message ID
static ULong_t fgUserThreadId
user (e.g. python) thread ID
static RooMathCoreReg dummy
void(* TGWin32CallBack)(void *)
virtual Bool_t ForwardCallBack(Bool_t sync)
if sync is kTRUE:
static ULong_t fgPingMessageId
ping message ID
Mother of all ROOT objects.
static Bool_t IsGloballyLocked()
Check the status of the lock.
virtual Double_t GetMilliSeconds()
returns elapsed time in milliseconds with microseconds precision
static Bool_t Ping()
send ping messsage to server thread
static void Unlock()
leave critical section