<commit_before>#pragma once

#include "queue.h"

struct condvar {
  struct spinlock lock;
  LIST_HEAD(waiters, proc) waiters;

#ifdef __cplusplus
  // Construct an uninitialized condvar.  This should be move-assigned
  // from an initialized condvar before being used.  This is
  // constexpr, so it can be used for global condvars without
  // incurring a static constructor.
  constexpr condvar()
    : lock(), waiters{} { }

  constexpr
  condvar(const char *name)
    : lock(name, LOCKSTAT_CONDVAR), waiters{} { }

  // Condvars cannot be copied.
  condvar(const condvar &o) = delete;
  condvar &operator=(const condvar &o) = delete;

  // Condvars can be moved.
  condvar(condvar &&o) = default;
  condvar &operator=(condvar &&o) = default;
#endif // __cplusplus
};<commit_msg>condvar: Make new/delete-able<commit_after>#pragma once

#include "queue.h"
#ifdef __cplusplus
#include "cpputil.hh"           // For NEW_DELETE_OPS
#endif

struct condvar {
  struct spinlock lock;
  LIST_HEAD(waiters, proc) waiters;

#ifdef __cplusplus
  // Construct an uninitialized condvar.  This should be move-assigned
  // from an initialized condvar before being used.  This is
  // constexpr, so it can be used for global condvars without
  // incurring a static constructor.
  constexpr condvar()
    : lock(), waiters{} { }

  constexpr
  condvar(const char *name)
    : lock(name, LOCKSTAT_CONDVAR), waiters{} { }

  // Condvars cannot be copied.
  condvar(const condvar &o) = delete;
  condvar &operator=(const condvar &o) = delete;

  // Condvars can be moved.
  condvar(condvar &&o) = default;
  condvar &operator=(condvar &&o) = default;

  NEW_DELETE_OPS(condvar);
#endif // __cplusplus
};
{'fraction_non_alphanumeric': 0.11137440758293839, 'fraction_numerical': 0.0, 'mean_word_length': 3.64010989010989, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '302874', 'n_tokens_mistral': 558, 'n_tokens_neox': 546, 'n_words': 176}