Welcome to mirror list, hosted at ThFree Co, Russian Federation.

lazy_threading.cc « intern « blenlib « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 803fd81a96d87ef54a4df12c636cdd3027042908 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* SPDX-License-Identifier: GPL-2.0-or-later */

#include "BLI_lazy_threading.hh"
#include "BLI_vector.hh"

namespace blender::lazy_threading {

/**
 * This is a #RawVector so that it can be destructed after Blender checks for memory leaks.
 */
thread_local RawVector<FunctionRef<void()>, 0> hint_receivers;

void send_hint()
{
  for (const FunctionRef<void()> &fn : hint_receivers) {
    fn();
  }
}

HintReceiver::HintReceiver(const FunctionRef<void()> fn)
{
  hint_receivers.append(fn);
}

HintReceiver::~HintReceiver()
{
  hint_receivers.pop_last();
}

}  // namespace blender::lazy_threading