<commit_before>//
// Created by per on 2016-04-08.
//

#ifndef KERNEL_EVENTLOOP_H
#define KERNEL_EVENTLOOP_H

#include <functional>
#include <stdio.h>
#include <deque>
#include <mutex>
#include "interrupts.h"
#include "concurrency.h"

class Eventloop {
private:
    std::deque<std::function<void(void)>> mQueue;
    InterruptLock mLock;
    WaitCond mCond;
public:
    Eventloop() : mQueue() {}

    template <class TFunc>
    void post(TFunc&& func) {
        mLock.lock();
        mQueue.push_back(std::move<TFunc>(func));
        mLock.unlock();
    }

    template <class TFunc>
    void postIntr(TFunc&& func) {
        mLock.lockIntr();
        mQueue.push_back(std::move<TFunc>(func));
        mLock.unlockIntr();
    }

    void deplete() {
        mLock.lock();<commit_msg>Forward function instead of moving.<commit_after>//
// Created by per on 2016-04-08.
//

#ifndef KERNEL_EVENTLOOP_H
#define KERNEL_EVENTLOOP_H

#include <functional>
#include <stdio.h>
#include <deque>
#include <mutex>
#include "interrupts.h"
#include "concurrency.h"

class Eventloop {
private:
    std::deque<std::function<void(void)>> mQueue;
    InterruptLock mLock;
    WaitCond mCond;
public:
    Eventloop() : mQueue() {}

    template <class TFunc>
    void post(TFunc&& func) {
        mLock.lock();
        mQueue.push_back(std::forward<TFunc>(func));
        mLock.unlock();
    }

    template <class TFunc>
    void postIntr(TFunc&& func) {
        mLock.lockIntr();
        mQueue.push_back(std::forward<TFunc>(func));
        mLock.unlockIntr();
    }

    void deplete() {
        mLock.lock();
{'fraction_non_alphanumeric': 0.14761306532663315, 'fraction_numerical': 0.010050251256281407, 'mean_word_length': 3.1484375, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '6758704', 'n_tokens_mistral': 583, 'n_tokens_neox': 554, 'n_words': 113}