MCPcopy Create free account
hub / github.com/TheHPXProject/hpx / add

Method add

libs/full/runtime_components/src/console_logging.cpp:160–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158 }
159
160 void pending_logs::add(message_type const& msg)
161 {
162 if (nullptr == hpx::get_runtime_ptr())
163 {
164 // This branch will be taken if it's too early or too late in the
165 // game. We do local logging only. Any queued messages which may be
166 // still left in the queue are logged locally as well.
167
168 // queue up the new message and log it with the rest of it
169 messages_type msgs;
170 {
171 std::lock_guard<queue_mutex_type> l(queue_mtx_);
172 queue_.push_back(msg);
173 queue_.swap(msgs);
174 }
175
176 fallback_console_logging_locked(msgs);
177 }
178 else if (is_active())
179 {
180 // This branch will be taken under normal circumstances. We queue
181 // up the message and either log it immediately (if we are on the
182 // console locality) or defer logging until 'max_pending' messages
183 // have been queued. Note: we can invoke send only from within a
184 // HPX-thread.
185 std::size_t size = 0;
186
187 {
188 std::lock_guard<queue_mutex_type> l(queue_mtx_);
189 queue_.push_back(msg);
190 size = queue_.size();
191 }
192
193 // Invoke actual logging immediately if we're on the console or
194 // if the number of waiting log messages is too large.
195 if (agas::is_console() || size > max_pending)
196 send();
197 }
198 else
199 {
200 // This branch will be taken if the runtime is up and running, but
201 // either the thread manager is not active or this is not invoked
202 // on a HPX-thread.
203
204 // Note: is_console can be called outside of a HPX-thread
205 if (!agas::is_console())
206 {
207 // queue it for delivery to the console
208 std::lock_guard<queue_mutex_type> l(queue_mtx_);
209 queue_.push_back(msg);
210 }
211 else
212 {
213 // log it locally on the console
214 messages_type msgs;
215 msgs.push_back(msg);
216 fallback_console_logging_locked(msgs);
217 }

Callers 6

console_loggingFunction · 0.45
load_componentsMethod · 0.45
parse_commandlineFunction · 0.45
handle_argumentsMethod · 0.45

Calls 6

sendFunction · 0.85
is_consoleFunction · 0.50
push_backMethod · 0.45
swapMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected