}
static void counters_init (MonoProfiler *profiler);
-static void counters_sample (MonoProfiler *profiler, uint64_t timestamp, gboolean threadless);
+static void counters_sample (MonoProfiler *profiler, uint64_t timestamp);
static void
safe_send (MonoProfiler *profiler)
safe_send (prof);
}
+static void
+send_if_needed_threadless (MonoProfiler *prof)
+{
+ if (PROF_TLS_GET ()->buffer->next)
+ safe_send_threadless (prof);
+}
+
static int
gc_reference (MonoObject *obj, MonoClass *klass, uintptr_t size, uintptr_t num, MonoObject **refs, uintptr_t *offsets, void *data)
{
}
static void
-counters_emit (MonoProfiler *profiler, gboolean threadless)
+counters_emit (MonoProfiler *profiler)
{
MonoCounterAgent *agent;
int len = 0;
EXIT_LOG;
- if (threadless)
- safe_send_threadless (profiler);
- else
- safe_send (profiler);
-
mono_os_mutex_unlock (&counters_mutex);
}
static void
-counters_sample (MonoProfiler *profiler, uint64_t timestamp, gboolean threadless)
+counters_sample (MonoProfiler *profiler, uint64_t timestamp)
{
MonoCounterAgent *agent;
MonoCounter *counter;
if (!counters_initialized)
return;
- counters_emit (profiler, threadless);
+ counters_emit (profiler);
buffer_size = 8;
buffer = calloc (1, buffer_size);
EXIT_LOG;
- if (threadless)
- safe_send_threadless (profiler);
- else
- safe_send (profiler);
-
mono_os_mutex_unlock (&counters_mutex);
}
static PerfCounterAgent *perfcounters = NULL;
static void
-perfcounters_emit (MonoProfiler *profiler, gboolean threadless)
+perfcounters_emit (MonoProfiler *profiler)
{
PerfCounterAgent *pcagent;
int len = 0;
}
EXIT_LOG;
-
- if (threadless)
- safe_send_threadless (profiler);
- else
- safe_send (profiler);
}
static gboolean
}
static void
-perfcounters_sample (MonoProfiler *profiler, uint64_t timestamp, gboolean threadless)
+perfcounters_sample (MonoProfiler *profiler, uint64_t timestamp)
{
PerfCounterAgent *pcagent;
int size;
mono_perfcounter_foreach (perfcounters_foreach, perfcounters);
- perfcounters_emit (profiler, threadless);
+ perfcounters_emit (profiler);
size =
EVENT_SIZE /* event */ +
EXIT_LOG;
- if (threadless)
- safe_send_threadless (profiler);
- else
- safe_send (profiler);
-
mono_os_mutex_unlock (&counters_mutex);
}
static void
-counters_and_perfcounters_sample (MonoProfiler *prof, gboolean threadless)
+counters_and_perfcounters_sample (MonoProfiler *prof)
{
static uint64_t start = -1;
uint64_t now;
start = current_time ();
now = current_time ();
- counters_sample (prof, (now - start) / 1000/ 1000, threadless);
- perfcounters_sample (prof, (now - start) / 1000/ 1000, threadless);
+ counters_sample (prof, (now - start) / 1000/ 1000);
+ perfcounters_sample (prof, (now - start) / 1000/ 1000);
}
#define COVERAGE_DEBUG(x) if (debug_coverage) {x}
EXIT_LOG;
- safe_send (prof);
+ send_if_needed (prof);
for (i = 0; i < coverage_data->len; i++) {
CoverageEntry *entry = (CoverageEntry *)coverage_data->pdata[i];
EXIT_LOG;
- safe_send (prof);
+ send_if_needed (prof);
}
method_id++;
EXIT_LOG;
- safe_send (prof);
+ send_if_needed (prof);
g_free (class_name);
}
EXIT_LOG;
- safe_send (prof);
+ send_if_needed (prof);
}
static void
in_shutdown = 1;
#ifndef DISABLE_HELPER_THREAD
- counters_and_perfcounters_sample (prof, FALSE);
+ counters_and_perfcounters_sample (prof);
dump_coverage (prof);
}
#endif
- counters_and_perfcounters_sample (prof, TRUE);
+ counters_and_perfcounters_sample (prof);
+
+ send_if_needed_threadless (prof);
buffer_lock_excl ();
continue;
if (FD_ISSET (perf_data [i].perf_fd, &rfds)) {
read_perf_mmap (prof, i);
- safe_send_threadless (prof);
+ send_if_needed_threadless (prof);
}
}
}
dump_unmanaged_coderefs (prof);
- if (logbuffer->next)
- safe_send_threadless (prof);
+ send_if_needed_threadless (prof);
}
return FALSE;
InterlockedWrite (&runtime_inited, 1);
#ifndef DISABLE_HELPER_THREAD
counters_init (profiler);
- counters_sample (profiler, 0, FALSE);
+ counters_sample (profiler, 0);
#endif
/* ensure the main thread data and startup are available soon */
safe_send (profiler);