Skip to content

Commit

Permalink
add TRACE_FLUSH_THRESHOLD
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers committed Oct 6, 2023
1 parent 39f13ed commit e5b87ba
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,22 @@
#include <unistd.h>
#endif

#define DEBUG_MODULE "trace"
#define DEBUG_LEVEL 5
#include <re_dbg.h>

#ifndef TRACE_BUFFER_SIZE
#define TRACE_BUFFER_SIZE 100000
#endif

enum {
TRACE_FLUSH_TMR = 10000,
};
#ifndef TRACE_FLUSH_THRESHOLD
#define TRACE_FLUSH_THRESHOLD 1000
#endif

#ifndef TRACE_FLUSH_TMR
#define TRACE_FLUSH_TMR 1000
#endif

#define DEBUG_MODULE "trace"
#define DEBUG_LEVEL 5
#include <re_dbg.h>

struct trace_event {
const char *name;
Expand Down Expand Up @@ -107,6 +112,13 @@ static int flush_worker(void *arg)
{
(void)arg;

mtx_lock(&trace.lock);
if (trace.event_count < TRACE_FLUSH_THRESHOLD) {
mtx_unlock(&trace.lock);
return 0;
}
mtx_unlock(&trace.lock);

re_trace_flush();

return 0;
Expand Down

0 comments on commit e5b87ba

Please sign in to comment.