<commit_before>#include "../../includes/event-loop-linux.h"
#include "../../includes/event-loop.h"

int uiLoopWakeup() {
  DEBUG("uiLoopWakeup\n");
  g_main_context_wakeup(NULL);
  DEBUG("uiLoopWakeup exit\n");
  // give main thread some time to react
  usleep(50 * 1000);
  return 0;
}

int uiEventsPending() {
  DEBUG("uiEventsPending\n");
  return gtk_events_pending();
}

int waitForNodeEvents(uv_loop_t* loop, int timeout) {
  DEBUG("uv_backend_fd\n");
  int nodeBackendFd = uv_backend_fd(loop);
  DEBUG_F("uv_backend_fd %d\n", nodeBackendFd);

  if (nodeBackendFd == -1) {
    fprintf(stderr, "Invalid node backend fd.\n");
    return 0;
  }

  struct epoll_event ev;
  DEBUG("epoll_wait\n");

  int ret = epoll_wait(nodeBackendFd, &ev, 1, timeout);
  struct heap* timer_heap = (struct heap*)&loop->timers;
  struct heap_node* timer_node = timer_heap->min;
  if (timer_node != NULL) {
    return 1;
  }

  DEBUG_F("epoll_wait %d\n", ret);
  return ret;
}<commit_msg>Fix loop on unix<commit_after>#include "../../includes/event-loop-linux.h"
#include "../../includes/event-loop.h"

int uiLoopWakeup() {
  DEBUG("uiLoopWakeup\n");
  g_main_context_wakeup(NULL);
  DEBUG("uiLoopWakeup exit\n");
  // give main thread some time to react
  usleep(50 * 1000);
  return 0;
}

int uiEventsPending() {
  DEBUG("uiEventsPending\n");
  return gtk_events_pending();
}

int waitForNodeEvents(uv_loop_t* loop, int timeout) {
  DEBUG("uv_backend_fd\n");
  int nodeBackendFd = uv_backend_fd(loop);
  DEBUG_F("uv_backend_fd %d\n", nodeBackendFd);

  if (nodeBackendFd == -1) {
    fprintf(stderr, "Invalid node backend fd.\n");
    return 0;
  }

  struct epoll_event ev;
  DEBUG("epoll_wait\n");

  int ret = epoll_wait(nodeBackendFd, &ev, 1, timeout);
  struct heap* timer_heap = (struct heap*)&loop->timer_heap;
  struct heap_node* timer_node = timer_heap->min;
  if (timer_node != NULL) {
    return 1;
  }

  DEBUG_F("epoll_wait %d\n", ret);
  return ret;
}
{'fraction_non_alphanumeric': 0.15581752947206562, 'fraction_numerical': 0.011276268580215274, 'mean_word_length': 4.083333333333333, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4597279', 'n_tokens_mistral': 758, 'n_tokens_neox': 748, 'n_words': 157}