<commit_before>#include "shared_mutex.hpp"

namespace turbo {
namespace threading {

shared_mutex::shared_mutex()
    :
	mutex_(),
	condition_(),
	read_counter_(0U),
	write_counter_(0U)
{ }

bool shared_mutex::try_lock_shared()
{
    std::unique_lock<std::mutex> lock(mutex_, std::defer_lock);
    if (lock.try_lock())
    {
	if (write_counter_ != 0U)
	{
	    wait_shareable(lock);
	}
	++read_counter_;
	return true;
    }
    return false;
}

void shared_mutex::lock_shared()
{
    std::unique_lock<std::mutex> lock(mutex_);
    if (write_counter_ != 0U);<commit_msg>fixed typo in lock_shared which made it wait unnecessarily when there are no writers<commit_after>#include "shared_mutex.hpp"

namespace turbo {
namespace threading {

shared_mutex::shared_mutex()
    :
	mutex_(),
	condition_(),
	read_counter_(0U),
	write_counter_(0U)
{ }

bool shared_mutex::try_lock_shared()
{
    std::unique_lock<std::mutex> lock(mutex_, std::defer_lock);
    if (lock.try_lock())
    {
	if (write_counter_ != 0U)
	{
	    wait_shareable(lock);
	}
	++read_counter_;
	return true;
    }
    return false;
}

void shared_mutex::lock_shared()
{
    std::unique_lock<std::mutex> lock(mutex_);
    if (write_counter_ != 0U)
{'fraction_non_alphanumeric': 0.14013266998341625, 'fraction_numerical': 0.006633499170812604, 'mean_word_length': 4.693396226415095, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4799171', 'n_tokens_mistral': 449, 'n_tokens_neox': 438, 'n_words': 80}