Skip to content

Commit

Permalink
avoid flush & addToNextBatch after destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
jingpeng committed Sep 12, 2023
1 parent 65a08c7 commit 790cfc4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions common/dangle/DangleContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,11 @@ namespace dangle {
m_done = false;

addToNextBatch([&] {
op();

if (!destroy) {
op();
} else {
DangleSysLog("addToNextBatch after DangleContext destroyed");
}
std::unique_lock<decltype(mutex)> lock(mutex);
m_done = true;
m_done_cv.notify_all();
Expand Down Expand Up @@ -153,6 +156,10 @@ namespace dangle {

// [GL thread] Do all the remaining work we can do on the GL thread
void flush(void) {
if (destroy) {
DangleSysLog("flush after DangleContext destroyed");
return;
}
// Keep a copy and clear backlog to minimize lock time
std::vector<Batch> copy;
{
Expand Down
2 changes: 1 addition & 1 deletion common/dangle/DanglePlatformUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace dangle {

#ifdef DANGLE_DEBUG
#ifdef __ANDROID__
#define DangleSysLog(fmt, ...) __android_log_print(ANDROID_LOG_ERROR, "Dangle", fmt, ##__VA_ARGS__)
#define DangleSysLog(fmt, ...) __android_log_print(ANDROID_LOG_ERROR, "DangleJNI", fmt, ##__VA_ARGS__)
#endif
#ifdef __APPLE__
#define DangleSysLog(fmt, ...) DangleiOSLog("Dangle: " fmt, ##__VA_ARGS__)
Expand Down

0 comments on commit 790cfc4

Please sign in to comment.