Skip to content

Commit

Permalink
Add commented out cout in UniffiCallInvoker
Browse files Browse the repository at this point in the history
  • Loading branch information
jhugman committed Sep 10, 2024
1 parent 9f0b60b commit 443a7a0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cpp/includes/UniffiCallInvoker.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#pragma once
#include <ReactCommon/CallInvoker.h>
#include <condition_variable>
#include <iostream>
#include <jsi/jsi.h>
#include <memory>
#include <mutex>
Expand Down Expand Up @@ -55,7 +56,11 @@ class UniffiCallInvoker {
* until it completes.
*/
void invokeBlocking(jsi::Runtime &rt, UniffiCallFunc &func) {
// static auto jobNo = 0;
// jobNo += 1;
// auto job = jobNo;
if (std::this_thread::get_id() == threadId_) {
// std::cout << "-- Invoking on the same thread" << std::endl;
func(rt);
} else {
std::mutex mtx;
Expand All @@ -67,17 +72,21 @@ class UniffiCallInvoker {
// This can be changed once that change is released.
// react::CallFunc wrapper = [&func, &mtx, &cv, &done](jsi::Runtime &rt) {
std::function<void()> wrapper = [&func, &rt, &mtx, &cv, &done]() {
// std::cout << "-- Invoking job " << job << std::endl;
func(rt);
// std::cout << "-- Finished in JS for job " << job << std::endl;
{
std::lock_guard<std::mutex> lock(mtx);
done = true;
}
cv.notify_one();
cv.notify_all();
};
// std::cout << "-- Scheduling job " << job << std::endl;
callInvoker_->invokeAsync(std::move(wrapper));

std::unique_lock<std::mutex> lock(mtx);
cv.wait(lock, [&done] { return done; });
// std::cout << "-- Unlocking after job " << job << std::endl;
}
}

Expand Down

0 comments on commit 443a7a0

Please sign in to comment.