]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MONITOR/AliDimIntNotifier.cxx
Coding convention violations: suppression
[u/mrichter/AliRoot.git] / MONITOR / AliDimIntNotifier.cxx
CommitLineData
c6d78c69 1// @(#)root/eve:$Id$
2// Author: Matevz Tadel 2007
3
4/**************************************************************************
5 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
7 * full copyright notice. *
8 **************************************************************************/
9
10#include "AliDimIntNotifier.h"
dc836d53 11#include <TError.h>
ba04bf55 12#include <signal.h>
c6d78c69 13
14//______________________________________________________________________________
15// Full description of AliDimIntNotifier
16//
17
18ClassImp(AliDimIntNotifier)
19
20Long_t AliDimIntNotifier::fgMainThreadId = 0;
21
22void AliDimIntNotifier::SetMainThreadId()
23{
24 fgMainThreadId = TThread::SelfId();
25}
26
27AliDimIntNotifier::AliDimIntNotifier(const TString& service) :
28 DimUpdatedInfo(service, -1),
4f6eef9f 29 fReThreader(),
c6d78c69 30 fNotifyLck(kTRUE),
c6d78c69 31 fLastMessage(-1)
32{
33 fReThreader.Connect("Timeout()", "AliDimIntNotifier", this, "DimMessage()");
34}
35
36void AliDimIntNotifier::StartTimer()
37{
38 fReThreader.Reset();
39 fReThreader.TurnOn();
49bacd14 40 pthread_kill((pthread_t)fgMainThreadId, SIGALRM);
c6d78c69 41}
42
43void AliDimIntNotifier::StopTimer()
44{
45 fReThreader.TurnOff();
46}
47
48void AliDimIntNotifier::infoHandler()
49{
50 // Handle DIM message
51
52 fNotifyLck.Lock();
53 fLastMessage = getData() ? getInt() : -1;
54 if (TThread::SelfId() != fgMainThreadId)
55 {
56 StartTimer();
c6d78c69 57 }
58 else
59 {
dc836d53 60 ::Warning("DIMinfoHandler", "DIM message received from CINT thread.");
c6d78c69 61 DimMessage();
62 }
63 fNotifyLck.UnLock();
64}
65
66void AliDimIntNotifier::infoHandlerTest(Int_t fake)
67{
68 // Fake handler for testing.
69
70 fNotifyLck.Lock();
71 fLastMessage = fake;
72 if (TThread::SelfId() != fgMainThreadId)
73 {
74 StartTimer();
c6d78c69 75 }
76 else
77 {
78 Warning("infoHandlerTest", "Was called from CINT thread ...");
79 DimMessage();
80 }
81 fNotifyLck.UnLock();
82}
83
84void AliDimIntNotifier::DimMessage(Int_t)
85{
86 StopTimer();
87 if (fLastMessage != -1)
88 {
89 Emit("DimMessage(Int_t)", fLastMessage);
c6d78c69 90 }
c6d78c69 91}