]>
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" | |
dc836d53 | 11 | #include <TError.h> |
ba04bf55 | 12 | #include <signal.h> |
c6d78c69 | 13 | |
14 | //______________________________________________________________________________ | |
15 | // Full description of AliDimIntNotifier | |
16 | // | |
17 | ||
18 | ClassImp(AliDimIntNotifier) | |
19 | ||
20 | Long_t AliDimIntNotifier::fgMainThreadId = 0; | |
21 | ||
22 | void AliDimIntNotifier::SetMainThreadId() | |
23 | { | |
24 | fgMainThreadId = TThread::SelfId(); | |
25 | } | |
26 | ||
27 | AliDimIntNotifier::AliDimIntNotifier(const TString& service) : | |
28 | DimUpdatedInfo(service, -1), | |
29 | fNotifyLck(kTRUE), | |
c6d78c69 | 30 | fLastMessage(-1) |
31 | { | |
32 | fReThreader.Connect("Timeout()", "AliDimIntNotifier", this, "DimMessage()"); | |
33 | } | |
34 | ||
35 | void AliDimIntNotifier::StartTimer() | |
36 | { | |
37 | fReThreader.Reset(); | |
38 | fReThreader.TurnOn(); | |
49bacd14 | 39 | pthread_kill((pthread_t)fgMainThreadId, SIGALRM); |
c6d78c69 | 40 | } |
41 | ||
42 | void AliDimIntNotifier::StopTimer() | |
43 | { | |
44 | fReThreader.TurnOff(); | |
45 | } | |
46 | ||
47 | void AliDimIntNotifier::infoHandler() | |
48 | { | |
49 | // Handle DIM message | |
50 | ||
51 | fNotifyLck.Lock(); | |
52 | fLastMessage = getData() ? getInt() : -1; | |
53 | if (TThread::SelfId() != fgMainThreadId) | |
54 | { | |
55 | StartTimer(); | |
c6d78c69 | 56 | } |
57 | else | |
58 | { | |
dc836d53 | 59 | ::Warning("DIMinfoHandler", "DIM message received from CINT thread."); |
c6d78c69 | 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(); | |
c6d78c69 | 74 | } |
75 | else | |
76 | { | |
77 | Warning("infoHandlerTest", "Was called from CINT thread ..."); | |
78 | DimMessage(); | |
79 | } | |
80 | fNotifyLck.UnLock(); | |
81 | } | |
82 | ||
83 | void AliDimIntNotifier::DimMessage(Int_t) | |
84 | { | |
85 | StopTimer(); | |
86 | if (fLastMessage != -1) | |
87 | { | |
88 | Emit("DimMessage(Int_t)", fLastMessage); | |
c6d78c69 | 89 | } |
c6d78c69 | 90 | } |