MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / ProcessEvents

Method ProcessEvents

Sources/Shared/Core/Logger.cpp:752–796  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

750 }
751
752 void LoggerBackend::ProcessEvents() noexcept
753 {
754 using namespace Implementation;
755
756 UpdateActiveThreadContextsCache();
757
758 // Read all frontend queues and cache the log statements and the metadata as TransitEvents
759 std::size_t cachedTransitEventsCount = PopulateTransitEventsFromFrontendQueues();
760
761 if (cachedTransitEventsCount != 0) {
762 // There are cached events to process
763 if (cachedTransitEventsCount < TransitEventsSoftLimit) {
764 // Process a single transit event, then give priority to reading the thread queues again
765 ProcessLowestTimestampTransitEvent();
766 } else {
767 // We want to process a batch of events
768 while (!HasPendingEventsForCachingWhenTransitEventBufferEmpty() && ProcessLowestTimestampTransitEvent()) {
769 // We need to be cautious because there are log messages in the lock-free queues that have not
770 // yet been cached in the transit event buffer. Logging only the cached messages can result
771 // in out-of-order log entries, as messages with larger timestamps in the queue might be missed.
772 }
773 }
774 } else {
775 // No cached transit events to process, minimal thread workload
776
777 // Force flush all remaining messages
778 FlushActiveSinks();
779
780 // Check for any dropped messages / blocked threads
781 //_check_failure_counter(_options.error_notifier);
782
783 ResyncRdtscClock();
784
785 // Also check if all queues are empty
786 bool queuesAndEventsEmpty = CheckThreadQueuesAndCachedTransitEventsEmpty();
787 if (queuesAndEventsEmpty) {
788 CleanUpInvalidatedThreadContexts();
789
790 // There is nothing left to do, and we can let this thread sleep for a while
791 _wakeUpEvent.Wait();
792
793 ResyncRdtscClock();
794 }
795 }
796 }
797#else
798 void LoggerBackend::DispatchEntryToSinks(TraceLevel level, std::uint64_t timestamp, const void* functionName, const void* content, std::uint32_t contentLength, StringView threadId) noexcept
799 {

Callers

nothing calls this directly

Calls 1

WaitMethod · 0.45

Tested by

no test coverage detected