Listing the "Blender Foundation" as copyright holder implied the Blender Foundation holds copyright to files which may include work from many developers. While keeping copyright on headers makes sense for isolated libraries, Blender's own code may be refactored or moved between files in a way that makes the per file copyright holders less meaningful. Copyright references to the "Blender Foundation" have been replaced with "Blender Authors", with the exception of `./extern/` since these this contains libraries which are more isolated, any changed to license headers there can be handled on a case-by-case basis. Some directories in `./intern/` have also been excluded: - `./intern/cycles/` it's own `AUTHORS` file is planned. - `./intern/opensubdiv/`. An "AUTHORS" file has been added, using the chromium projects authors file as a template. Design task: #110784 Ref !110783.
53 lines
1.2 KiB
C++
53 lines
1.2 KiB
C++
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#include "BLI_lazy_threading.hh"
|
|
#include "BLI_stack.hh"
|
|
#include "BLI_vector.hh"
|
|
|
|
namespace blender::lazy_threading {
|
|
|
|
/**
|
|
* This uses a "raw" stack and vector so that it can be destructed after Blender checks for memory
|
|
* leaks. A new list of receivers is created whenever an isolated region is entered to avoid
|
|
* deadlocks.
|
|
*/
|
|
using HintReceivers = RawStack<RawVector<FunctionRef<void()>, 0>, 0>;
|
|
static thread_local HintReceivers hint_receivers = []() {
|
|
HintReceivers receivers;
|
|
/* Make sure there is always at least one vector. */
|
|
receivers.push_as();
|
|
return receivers;
|
|
}();
|
|
|
|
void send_hint()
|
|
{
|
|
for (const FunctionRef<void()> &fn : hint_receivers.peek()) {
|
|
fn();
|
|
}
|
|
}
|
|
|
|
HintReceiver::HintReceiver(const FunctionRef<void()> fn)
|
|
{
|
|
hint_receivers.peek().append(fn);
|
|
}
|
|
|
|
HintReceiver::~HintReceiver()
|
|
{
|
|
hint_receivers.peek().pop_last();
|
|
}
|
|
|
|
ReceiverIsolation::ReceiverIsolation()
|
|
{
|
|
hint_receivers.push_as();
|
|
}
|
|
|
|
ReceiverIsolation::~ReceiverIsolation()
|
|
{
|
|
BLI_assert(hint_receivers.peek().is_empty());
|
|
hint_receivers.pop();
|
|
}
|
|
|
|
} // namespace blender::lazy_threading
|