MCPcopy Create free account
hub / github.com/armory3d/armory / handle_message_queue

Function handle_message_queue

armorcore/Sources/worker.cpp:88–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86 }
87
88 void handle_message_queue(Isolate* isolate, const Global<Context>& context, MessageQueue* messageQueue) {
89 if (messageQueue->messageFunc.IsEmpty()) {
90 return;
91 }
92
93 HandleScope scope(isolate);
94 Local<Context> current_context = Local<Context>::New(isolate, context);
95 Context::Scope context_scope(current_context);
96
97 kinc_mutex_lock(&messageQueue->messageMutex);
98
99 for (WorkerMessage& message : messageQueue->messages) {
100 MaybeLocal<Value> value = JSON::Parse(current_context, String::NewFromUtf8(isolate, message.message, NewStringType::kNormal, message.length).ToLocalChecked());
101 delete[] message.message;
102 Local<Object> object = Object::New(isolate);
103 object->Set(current_context, String::NewFromUtf8(isolate, "data").ToLocalChecked(), value.ToLocalChecked());
104 Local<Value> args[] = { object };
105
106 Local<Function> message_func = messageQueue->messageFunc.Get(isolate);
107 message_func->Call(current_context, current_context->Global(), 1, args);
108 }
109
110 messageQueue->messages.clear();
111
112 kinc_mutex_unlock(&messageQueue->messageMutex);
113 }
114
115 void handle_exception(Isolate* isolate, TryCatch* try_catch) {
116 MaybeLocal<Value> trace = try_catch->StackTrace(isolate->GetCurrentContext());

Callers 2

worker_thread_funcFunction · 0.85
handle_worker_messagesFunction · 0.85

Calls 7

ToLocalCheckedMethod · 0.80
IsEmptyMethod · 0.45
SetMethod · 0.45
GetMethod · 0.45
CallMethod · 0.45
GlobalMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected