<commit_before>#include <qi/signalspy.hpp>
#include <qi/log.hpp>

qiLogCategory("qi.signalspy");

namespace qi
{
namespace detail
{
  struct WaitTracking
  {
    WaitTracking(qi::Signal<void>& signal) : trackedSignal(signal) {}
    qi::Signal<void>& trackedSignal;
    SignalLink signalLink;
    Future<void> timingOut;
    Promise<bool> waitingPromise;

    void untrack()
    {
      QI_ASSERT(!waitingPromise.future().isRunning()); // just a security
      trackedSignal.disconnect(signalLink);
      timingOut.cancel();
    }
  };
} // detail

SignalSpy::SignalSpy(qi::AnyObject& object, const std::string& signalOrPropertyName)
  : _records()
{
  object.connect(
        signalOrPropertyName,
        qi::AnyFunction::fromDynamicFunction(
          stranded([this](qi::AnyReferenceVector anything)
  {
    return this->recordAnyCallback(anything);
  })));
}<commit_msg>Signal Spy: make untracking the signal be non-blocking<commit_after>#include <qi/signalspy.hpp>
#include <qi/log.hpp>

qiLogCategory("qi.signalspy");

namespace qi
{
namespace detail
{
  struct WaitTracking
  {
    WaitTracking(qi::Signal<void>& signal) : trackedSignal(signal) {}
    qi::Signal<void>& trackedSignal;
    SignalLink signalLink;
    Future<void> timingOut;
    Promise<bool> waitingPromise;

    Future<void> untrack()
    {
      QI_ASSERT(!waitingPromise.future().isRunning()); // just a security
      timingOut.cancel();
      return trackedSignal.disconnectAsync(signalLink).andThen([](bool){});
    }
  };
} // detail

SignalSpy::SignalSpy(qi::AnyObject& object, const std::string& signalOrPropertyName)
  : _records()
{
  object.connect(
        signalOrPropertyName,
        qi::AnyFunction::fromDynamicFunction(
          stranded([this](qi::AnyReferenceVector anything)
  {
    return this->recordAnyCallback(anything);
  })));
}
{'fraction_non_alphanumeric': 0.13613996719518862, 'fraction_numerical': 0.0, 'mean_word_length': 4.154929577464789, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 18, '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': '3357781', 'n_tokens_mistral': 595, 'n_tokens_neox': 559, 'n_words': 96}