| 2132 | } |
| 2133 | |
| 2134 | void G4VisManager::EndOfEventKernel (const G4Event* currentEvent) |
| 2135 | { |
| 2136 | // Note: we are still subject to the mutex lock with visEndOfEventMutex |
| 2137 | |
| 2138 | // Discard event if fDrawEventOnlyIfToBeKept flag is set unless the |
| 2139 | // user has requested the event to be kept. |
| 2140 | if (fDrawEventOnlyIfToBeKept) { |
| 2141 | if (!currentEvent->KeepTheEventFlag()) return; |
| 2142 | } |
| 2143 | |
| 2144 | if (G4Threading::IsMultithreadedApplication()) { |
| 2145 | |
| 2146 | // Wait if too many events in the queue. |
| 2147 | G4MUTEXLOCK(&mtVisSubThreadMutex); |
| 2148 | std::size_t eventQueueSize = mtVisEventQueue.size(); |
| 2149 | G4MUTEXUNLOCK(&mtVisSubThreadMutex); |
| 2150 | |
| 2151 | G4bool eventQueueFull = false; |
| 2152 | while (fMaxEventQueueSize > 0 && (G4int)eventQueueSize >= fMaxEventQueueSize) { |
| 2153 | |
| 2154 | if (fWaitOnEventQueueFull) { |
| 2155 | |
| 2156 | static G4bool warned = false; |
| 2157 | if (!warned) { |
| 2158 | G4warn << |
| 2159 | "WARNING: The number of events in the visualisation queue has exceeded" |
| 2160 | "\n the maximum, " |
| 2161 | << fMaxEventQueueSize << |
| 2162 | ".\n If, during a multithreaded run, the simulation gets ahead of the" |
| 2163 | "\n visualisation by more than this maximum, the simulation is delayed" |
| 2164 | "\n until the vis sub-thread has drawn a few more events and removed them" |
| 2165 | "\n from the queue. You may change this maximum number of events with" |
| 2166 | "\n \"/vis/multithreading/maxEventQueueSize <N>\", where N is the maximum" |
| 2167 | "\n number you wish to allow. N <= 0 means \"unlimited\"." |
| 2168 | "\n Alternatively you may choose to discard events for drawing by setting" |
| 2169 | "\n \"/vis/multithreading/actionOnEventQueueFull discard\"." |
| 2170 | "\n To avoid visualisation altogether: \"/vis/disable\"." |
| 2171 | "\n And maybe \"/tracking/storeTrajectories 0\"." |
| 2172 | << G4endl; |
| 2173 | warned = true; |
| 2174 | } |
| 2175 | |
| 2176 | // Wait a while to give event drawing time to reduce the queue... |
| 2177 | std::this_thread::sleep_for(std::chrono::milliseconds(100)); |
| 2178 | |
| 2179 | } else { |
| 2180 | |
| 2181 | static G4bool warned = false; |
| 2182 | if (!warned) { |
| 2183 | G4warn << |
| 2184 | "WARNING: The number of events in the visualisation queue has exceeded" |
| 2185 | "\n the maximum, " |
| 2186 | << fMaxEventQueueSize << |
| 2187 | ".\n Some events have been discarded for drawing. You may change this" |
| 2188 | "\n behaviour with \"/vis/multithreading/actionOnEventQueueFull wait\"." |
| 2189 | "\n To avoid visualisation altogether: \"/vis/disable\"." |
| 2190 | "\n And maybe \"/tracking/storeTrajectories 0\"." |
| 2191 | << G4endl; |
nothing calls this directly
no test coverage detected