<commit_before>/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#include "config.h"

#include <algorithm>

#include "ep_engine.h"
#include "tapconnmap.hh"
#include "tapconnection.hh"

size_t TapConnMap::vbConnLockNum = 8;


/**
 * Dispatcher task to free the resource of a tap connection.
 */
class TapConnectionReaperCallback : public DispatcherCallback {
public:
    TapConnectionReaperCallback(EventuallyPersistentEngine &e, connection_t &conn)
        : engine(e), connection(conn)
    {
        std::stringstream ss;
        ss << "Reaping tap connection: " << connection->getName();
        descr = ss.str();
    }

    bool callback(Dispatcher &, TaskId &) {
        TapProducer *tp = dynamic_cast<TapProducer*>(connection.get());
        if (tp) {
            tp->clearQueues();
            engine.getTapConnMap().removeVBTapConnections(connection);
        }
        return false;
    }

    std::string description() {
        return descr;
    }<commit_msg>MB-8861 Increase the number of vbucket / tap producer map locks<commit_after>/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#include "config.h"

#include <algorithm>

#include "ep_engine.h"
#include "tapconnmap.hh"
#include "tapconnection.hh"

size_t TapConnMap::vbConnLockNum = 32;


/**
 * Dispatcher task to free the resource of a tap connection.
 */
class TapConnectionReaperCallback : public DispatcherCallback {
public:
    TapConnectionReaperCallback(EventuallyPersistentEngine &e, connection_t &conn)
        : engine(e), connection(conn)
    {
        std::stringstream ss;
        ss << "Reaping tap connection: " << connection->getName();
        descr = ss.str();
    }

    bool callback(Dispatcher &, TaskId &) {
        TapProducer *tp = dynamic_cast<TapProducer*>(connection.get());
        if (tp) {
            tp->clearQueues();
            engine.getTapConnMap().removeVBTapConnections(connection);
        }
        return false;
    }

    std::string description() {
        return descr;
    }
{'fraction_non_alphanumeric': 0.13274768179599805, 'fraction_numerical': 0.005368472425573451, 'mean_word_length': 3.01174168297456, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 11, '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': '7512278', 'n_tokens_mistral': 651, 'n_tokens_neox': 617, 'n_words': 145}