]>
Commit | Line | Data |
---|---|---|
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" | |
11 | ||
12 | ||
13 | //______________________________________________________________________________ | |
14 | // Full description of AliDimIntNotifier | |
15 | // | |
16 | ||
17 | ClassImp(AliDimIntNotifier) | |
18 | ||
19 | Long_t AliDimIntNotifier::fgMainThreadId = 0; | |
20 | ||
21 | void AliDimIntNotifier::SetMainThreadId() | |
22 | { | |
23 | fgMainThreadId = TThread::SelfId(); | |
24 | } | |
25 | ||
26 | AliDimIntNotifier::AliDimIntNotifier(const TString& service) : | |
27 | DimUpdatedInfo(service, -1), | |
28 | fNotifyLck(kTRUE), | |
29 | fNotifyCnd(&fNotifyLck), | |
30 | fLastMessage(-1) | |
31 | { | |
32 | fReThreader.Connect("Timeout()", "AliDimIntNotifier", this, "DimMessage()"); | |
33 | } | |
34 | ||
35 | void AliDimIntNotifier::StartTimer() | |
36 | { | |
37 | fReThreader.Reset(); | |
38 | fReThreader.TurnOn(); | |
39 | } | |
40 | ||
41 | void AliDimIntNotifier::StopTimer() | |
42 | { | |
43 | fReThreader.TurnOff(); | |
44 | } | |
45 | ||
46 | void AliDimIntNotifier::infoHandler() | |
47 | { | |
48 | // Handle DIM message | |
49 | ||
50 | fNotifyLck.Lock(); | |
51 | fLastMessage = getData() ? getInt() : -1; | |
52 | if (TThread::SelfId() != fgMainThreadId) | |
53 | { | |
54 | StartTimer(); | |
55 | fNotifyCnd.Wait(); | |
56 | } | |
57 | else | |
58 | { | |
59 | Warning("infoHandler", "DIM message received from CINT thread."); | |
60 | DimMessage(); | |
61 | } | |
62 | fNotifyLck.UnLock(); | |
63 | } | |
64 | ||
65 | void AliDimIntNotifier::infoHandlerTest(Int_t fake) | |
66 | { | |
67 | // Fake handler for testing. | |
68 | ||
69 | fNotifyLck.Lock(); | |
70 | fLastMessage = fake; | |
71 | if (TThread::SelfId() != fgMainThreadId) | |
72 | { | |
73 | StartTimer(); | |
74 | fNotifyCnd.Wait(); | |
75 | } | |
76 | else | |
77 | { | |
78 | Warning("infoHandlerTest", "Was called from CINT thread ..."); | |
79 | DimMessage(); | |
80 | } | |
81 | fNotifyLck.UnLock(); | |
82 | } | |
83 | ||
84 | void AliDimIntNotifier::DimMessage(Int_t) | |
85 | { | |
86 | StopTimer(); | |
87 | if (fLastMessage != -1) | |
88 | { | |
89 | Emit("DimMessage(Int_t)", fLastMessage); | |
90 | printf("Notify %d\n", fLastMessage); | |
91 | } | |
92 | else | |
93 | { | |
94 | printf("NOTNotify %d\n", fLastMessage); | |
95 | } | |
96 | fNotifyLck.Lock(); | |
97 | fNotifyCnd.Signal(); | |
98 | fNotifyLck.UnLock(); | |
99 | } |