-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into to-globe-rectangle
- Loading branch information
Showing
18 changed files
with
586 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,66 @@ | ||
#include "CesiumAsync/Impl/QueuedScheduler.h" | ||
|
||
using namespace CesiumAsync::CesiumImpl; | ||
#include <condition_variable> | ||
#include <mutex> | ||
|
||
// Hackily use Async++'s internal fifo_queue. We could copy it instead - it's | ||
// not much code - but why create the duplication? However, we are assuming that | ||
// Async++'s source (not just headers) are available while building | ||
// cesium-native. If that's a problem in some context, we'll need to do that | ||
// duplication of fifo_queue after all. | ||
#include <async++/../../src/fifo_queue.h> | ||
|
||
namespace CesiumAsync::CesiumImpl { | ||
|
||
struct QueuedScheduler::Impl { | ||
async::detail::fifo_queue queue; | ||
std::mutex mutex; | ||
std::condition_variable conditionVariable; | ||
}; | ||
|
||
QueuedScheduler::QueuedScheduler() : _pImpl(std::make_unique<Impl>()) {} | ||
QueuedScheduler::~QueuedScheduler() = default; | ||
|
||
void QueuedScheduler::schedule(async::task_run_handle t) { | ||
this->_scheduler.schedule(std::move(t)); | ||
std::unique_lock<std::mutex> guard(this->_pImpl->mutex); | ||
this->_pImpl->queue.push(std::move(t)); | ||
|
||
// Notify listeners that there is new work. | ||
this->_pImpl->conditionVariable.notify_all(); | ||
} | ||
|
||
void QueuedScheduler::dispatchQueuedContinuations() { | ||
auto scope = this->immediate.scope(); | ||
this->_scheduler.run_all_tasks(); | ||
while (this->dispatchZeroOrOneContinuation()) { | ||
} | ||
} | ||
|
||
bool QueuedScheduler::dispatchZeroOrOneContinuation() { | ||
auto scope = this->immediate.scope(); | ||
return this->_scheduler.try_run_one_task(); | ||
return this->dispatchInternal(false); | ||
} | ||
|
||
bool QueuedScheduler::dispatchInternal(bool blockIfNoTasks) { | ||
async::task_run_handle t; | ||
|
||
{ | ||
std::unique_lock<std::mutex> guard(this->_pImpl->mutex); | ||
t = this->_pImpl->queue.pop(); | ||
if (blockIfNoTasks && !t) { | ||
this->_pImpl->conditionVariable.wait(guard); | ||
} | ||
} | ||
|
||
if (t) { | ||
auto scope = this->immediate.scope(); | ||
t.run(); | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
void QueuedScheduler::unblock() { | ||
std::unique_lock<std::mutex> guard(this->_pImpl->mutex); | ||
this->_pImpl->conditionVariable.notify_all(); | ||
} | ||
|
||
} // namespace CesiumAsync::CesiumImpl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
CesiumGltf/generated/include/CesiumGltf/ExtensionCesiumPrimitiveOutline.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// This file was generated by generate-classes. | ||
// DO NOT EDIT THIS FILE! | ||
#pragma once | ||
|
||
#include "CesiumGltf/Library.h" | ||
|
||
#include <CesiumUtility/ExtensibleObject.h> | ||
|
||
#include <cstdint> | ||
|
||
namespace CesiumGltf { | ||
/** | ||
* @brief glTF extension for indicating that some edges of a primitive's | ||
* triangles should be outlined. | ||
*/ | ||
struct CESIUMGLTF_API ExtensionCesiumPrimitiveOutline final | ||
: public CesiumUtility::ExtensibleObject { | ||
static inline constexpr const char* TypeName = | ||
"ExtensionCesiumPrimitiveOutline"; | ||
static inline constexpr const char* ExtensionName = | ||
"CESIUM_primitive_outline"; | ||
|
||
/** | ||
* @brief The index of the accessor providing the list of highlighted lines at | ||
* the edge of this primitive's triangles. | ||
*/ | ||
int32_t indices = -1; | ||
}; | ||
} // namespace CesiumGltf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.