Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4VisCommandsMultithreading.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4VisCommandsMultithreading.cc 88742 2015-03-08 13:12:57Z allison $
28 
29 // /vis/multithreading commands - John Allison 29th September 2015
30 
31 #ifdef G4MULTITHREADED
32 
34 
35 #include "G4UIcmdWithAnInteger.hh"
36 #include "G4UIcmdWithAString.hh"
37 #include "G4VisManager.hh"
38 
40 
41 G4VisCommandMultithreadingActionOnEventQueueFull::G4VisCommandMultithreadingActionOnEventQueueFull()
42 {
43  G4bool omitable;
44  fpCommand = new G4UIcmdWithAString("/vis/multithreading/actionOnEventQueueFull", this);
45  fpCommand->SetGuidance("When event queue for drawing gets full:");
46  fpCommand->SetGuidance("wait: event processing waits for vis manager to catch up.");
47  fpCommand->SetGuidance("discard: events are discarded for drawing.");
48  fpCommand->SetCandidates("wait discard");
49  fpCommand->SetParameterName ("wait", omitable = true);
50  fpCommand->SetDefaultValue ("wait");
51 }
52 
53 G4VisCommandMultithreadingActionOnEventQueueFull::~G4VisCommandMultithreadingActionOnEventQueueFull()
54 {
55  delete fpCommand;
56 }
57 
58 G4String G4VisCommandMultithreadingActionOnEventQueueFull::GetCurrentValue(G4UIcommand*)
59 {
60  return "";
61 }
62 
63 void G4VisCommandMultithreadingActionOnEventQueueFull::SetNewValue(G4UIcommand*, G4String newValue)
64 {
65  G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
66 
67  if (newValue == "wait") {
68  fpVisManager->SetWaitOnEventQueueFull(true);
69  } else {
70  fpVisManager->SetWaitOnEventQueueFull(false);
71  }
72 
73  if (verbosity >= G4VisManager::confirmations) {
74  G4cout <<
75  "When event queue for drawing is full,";
76  if (fpVisManager->GetWaitOnEventQueueFull()) {
77  G4cout << " event processing will wait";
78  } else {
79  G4cout << " events will be discarded for drawing";
80  }
81  G4cout << G4endl;
82  }
83 }
84 
86 
87 G4VisCommandMultithreadingMaxEventQueueSize::G4VisCommandMultithreadingMaxEventQueueSize()
88 {
89  G4bool omitable;
90  fpCommand = new G4UIcmdWithAnInteger("/vis/multithreading/maxEventQueueSize", this);
91  fpCommand->SetGuidance
92  ("Defines maximum event queue size. N <=0 means \"unlimited\".");
93  fpCommand->SetGuidance
94  ("If adding an event to the visualisation event queue would cause the"
95  " queue size to exceed this value:");
96  fpCommand->SetGuidance
97  (" if actionOnEventQueueFull==wait the worker threads are paused for a short"
98  " time to give the visualisation manager a chance to catch up.");
99  fpCommand->SetGuidance
100  (" if actionOnEventQueueFull==discard the event is discarded for drawing.");
101  fpCommand->SetParameterName ("maxSize", omitable = true);
102  fpCommand->SetDefaultValue (100);
103 }
104 
105 G4VisCommandMultithreadingMaxEventQueueSize::~G4VisCommandMultithreadingMaxEventQueueSize()
106 {
107  delete fpCommand;
108 }
109 
110 G4String G4VisCommandMultithreadingMaxEventQueueSize::GetCurrentValue(G4UIcommand*)
111 {
112  return "";
113 }
114 
115 void G4VisCommandMultithreadingMaxEventQueueSize::SetNewValue(G4UIcommand*, G4String newValue)
116 {
117  G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
118 
119  G4int maxEventQueueSize = fpCommand->GetNewIntValue(newValue);
120  fpVisManager->SetMaxEventQueueSize(maxEventQueueSize);
121 
122  if (verbosity >= G4VisManager::confirmations) {
123  G4cout <<
124  "Maximum event queue size has been set to "
125  << fpVisManager->GetMaxEventQueueSize()
126  << G4endl;
127  }
128 }
129 
130 #endif
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
#define G4endl
Definition: G4ios.hh:61