void ScriptRunner::notifyScriptReady(ScriptLoader* scriptLoader, ExecutionType executionType) { RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(scriptLoader); switch (executionType) { case ASYNC_EXECUTION: // RELEASE_ASSERT makes us crash in a controlled way in error cases // where the ScriptLoader is associated with the wrong ScriptRunner // (otherwise we'd cause a use-after-free in ~ScriptRunner when it tries // to detach). RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_pendingAsyncScripts.contains(scriptLoader)); m_pendingAsyncScripts.remove(scriptLoader); m_asyncScriptsToExecuteSoon.append(scriptLoader); postTask(BLINK_FROM_HERE); break; case IN_ORDER_EXECUTION: RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(m_numberOfInOrderScriptsWithPendingNotification > 0); m_numberOfInOrderScriptsWithPendingNotification--; while (!m_pendingInOrderScripts.isEmpty() && m_pendingInOrderScripts.first()->isReady()) { m_inOrderScriptsToExecuteSoon.append(m_pendingInOrderScripts.takeFirst()); postTask(BLINK_FROM_HERE); } break; } }
void ScriptRunner::resume() { DCHECK(m_isSuspended); m_isSuspended = false; for (size_t i = 0; i < m_asyncScriptsToExecuteSoon.size(); ++i) { postTask(BLINK_FROM_HERE); } for (size_t i = 0; i < m_inOrderScriptsToExecuteSoon.size(); ++i) { postTask(BLINK_FROM_HERE); } }
void ScriptRunner::notifyScriptReady(ScriptLoader* scriptLoader, AsyncExecutionType executionType) { SECURITY_CHECK(scriptLoader); switch (executionType) { case Async: // RELEASE_ASSERT makes us crash in a controlled way in error cases // where the ScriptLoader is associated with the wrong ScriptRunner // (otherwise we'd cause a use-after-free in ~ScriptRunner when it tries // to detach). SECURITY_CHECK(m_pendingAsyncScripts.contains(scriptLoader)); m_pendingAsyncScripts.remove(scriptLoader); m_asyncScriptsToExecuteSoon.append(scriptLoader); postTask(BLINK_FROM_HERE); break; case InOrder: SECURITY_CHECK(m_numberOfInOrderScriptsWithPendingNotification > 0); m_numberOfInOrderScriptsWithPendingNotification--; scheduleReadyInOrderScripts(); break; case None: NOTREACHED(); break; } }
blink::WebThread& HTMLParserThread::platformThread() { if (!isRunning()) { m_thread = adoptPtr(blink::Platform::current()->createThread("HTMLParserThread")); postTask(WTF::bind(&HTMLParserThread::setupHTMLParserThread, this)); } return *m_thread; }
void mytimer_fired(){ postTask(dataTask,3); //add //PhotoTempM_ExternalPhotoADC_getData(); //PhotoTempM_ExternalPhotoADC_dataReady(6); }
void WorkerGlobalScope::addMessage(MessageSource source, MessageLevel level, const String& message, const String& sourceURL, unsigned lineNumber, ScriptState* state) { if (!isContextThread()) { postTask(AddConsoleMessageTask::create(source, level, message)); return; } thread()->workerReportingProxy().postConsoleMessageToWorkerObject(source, level, message, lineNumber, sourceURL); addMessageToWorkerConsole(source, level, message, sourceURL, lineNumber, 0, state); }
void WorkerContext::addMessage(MessageSource source, MessageLevel level, const String& message, const String& sourceURL, unsigned lineNumber, PassRefPtr<ScriptCallStack> callStack, ScriptState* state, unsigned long requestIdentifier) { if (!isContextThread()) { postTask(AddConsoleMessageTask::create(source, level, message)); return; } thread()->workerReportingProxy().postConsoleMessageToWorkerObject(source, level, message, lineNumber, sourceURL); addMessageToWorkerConsole(source, level, message, sourceURL, lineNumber, callStack, state, requestIdentifier); }
void WorkerGlobalScope::addConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage> prpConsoleMessage) { RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = prpConsoleMessage; if (!isContextThread()) { postTask(AddConsoleMessageTask::create(consoleMessage->source(), consoleMessage->level(), consoleMessage->message())); return; } thread()->workerReportingProxy().reportConsoleMessage(consoleMessage); addMessageToWorkerConsole(consoleMessage.release()); }
void ScriptExecutionContext::processMessagePortMessagesSoon() { if (m_willProcessMessagePortMessagesSoon) return; m_willProcessMessagePortMessagesSoon = true; postTask([] (ScriptExecutionContext& context) { context.dispatchMessagePortEvents(); }); }
void WorkerGlobalScope::addMessage(MessageSource source, MessageLevel level, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, RefPtr<ScriptCallStack>&& callStack, JSC::ExecState* state, unsigned long requestIdentifier) { if (!isContextThread()) { postTask(AddConsoleMessageTask(source, level, StringCapture(message))); return; } thread().workerReportingProxy().postConsoleMessageToWorkerObject(source, level, message, lineNumber, columnNumber, sourceURL); addMessageToWorkerConsole(source, level, message, sourceURL, lineNumber, columnNumber, WTF::move(callStack), state, requestIdentifier); }
void WorkerContext::close() { if (m_closing) return; m_closing = true; // Let current script run to completion but prevent future script evaluations. m_script->forbidExecution(WorkerScriptController::LetRunningScriptFinish); postTask(CloseWorkerContextTask::create()); }
void WorkerGlobalScope::addConsoleMessage(std::unique_ptr<Inspector::ConsoleMessage> message) { if (!isContextThread()) { postTask(AddConsoleMessageTask(message->source(), message->level(), StringCapture(message->message()))); return; } thread().workerReportingProxy().postConsoleMessageToWorkerObject(message->source(), message->level(), message->message(), message->line(), message->column(), message->url()); addMessageToWorkerConsole(WTFMove(message)); }
void HTMLParserThread::postTask(PassOwnPtr<CrossThreadClosure> closure) { ASSERT(isMainThread()); if (!m_thread) { m_thread = WebThreadSupportingGC::create("HTMLParserThread"); postTask(threadSafeBind(&HTMLParserThread::setupHTMLParserThread, AllowCrossThreadAccess(this))); } m_thread->postTask(BLINK_FROM_HERE, closure); }
void WorkerGlobalScope::addConsoleMessage(MessageSource source, MessageLevel level, const String& message, unsigned long requestIdentifier) { if (!isContextThread()) { postTask(AddConsoleMessageTask::create(source, level, message)); return; } thread()->workerReportingProxy().postConsoleMessageToWorkerObject(source, level, message, 0, 0, String()); addMessageToWorkerConsole(source, level, message, String(), 0, 0, 0, 0, requestIdentifier); }
void ExecutionContext::resumeScheduledTasks() { resumeActiveDOMObjects(); tasksWereResumed(); // We need finish stack unwiding before running next task because it can suspend this context. if (m_isRunSuspendableTasksScheduled) return; m_isRunSuspendableTasksScheduled = true; postTask(FROM_HERE, createSameThreadTask(&ExecutionContext::runSuspendableTasks, this)); }
void ScriptRunner::scheduleReadyInOrderScripts() { while (!m_pendingInOrderScripts.isEmpty() && m_pendingInOrderScripts.first()->isReady()) { // A ScriptLoader that failed is responsible for cancelling itself // notifyScriptLoadError(); it continues this draining of ready scripts. if (m_pendingInOrderScripts.first()->errorOccurred()) break; m_inOrderScriptsToExecuteSoon.append(m_pendingInOrderScripts.takeFirst()); postTask(BLINK_FROM_HERE); } }
void WorkerGlobalScope::close() { if (m_closing) return; // Let current script run to completion but prevent future script evaluations. // After m_closing is set, all the tasks in the queue continue to be fetched but only // tasks with isCleanupTask()==true will be executed. m_closing = true; postTask(CloseWorkerGlobalScopeTask::create()); }
void HTMLParserThread::postTask(std::unique_ptr<CrossThreadClosure> closure) { ASSERT(isMainThread()); if (!m_thread) { m_thread = WebThreadSupportingGC::create("HTMLParserThread", BlinkGC::MainThreadHeapMode); postTask(crossThreadBind(&HTMLParserThread::setupHTMLParserThread, crossThreadUnretained(this))); } m_thread->postTask(BLINK_FROM_HERE, std::move(closure)); }
inline void TimerM_HandleFire(void) { uint8_t i; uint16_t int_out; TimerM_setIntervalFlag = 1; { _atomic_t _atomic = _atomic_start(); { int_out = TimerM_interval_outstanding; TimerM_interval_outstanding = 0; } _atomic_end(_atomic); } if (TimerM_mState) { for (i = 0; i < NUM_TIMERS; i++) { if (TimerM_mState & (0x1L << i)) { TimerM_mTimerList[i].ticksLeft -= int_out; if (TimerM_mTimerList[i].ticksLeft <= 2) { if (postTask(TimerM_signalOneTimer, 7)) { if (TimerM_mTimerList[i].type == TIMER_REPEAT) { TimerM_mTimerList[i].ticksLeft += TimerM_mTimerList[i].ticks; } else { TimerM_mState &= ~(0x1L << i); } TimerM_enqueue(i); } else { { } ; TimerM_mTimerList[i].ticksLeft = TimerM_mInterval; } } } } } { _atomic_t _atomic = _atomic_start(); int_out = TimerM_interval_outstanding; _atomic_end(_atomic); } if (int_out == 0) { TimerM_adjustInterval(); } }
//------------------------------------------------------------------------- void StandardSocketSend(uint16_t port, uint16_t address, uint8_t msglength, uint8_t * msg) { // #ifdef PLATFORM_AVR_IRIS // sleepThread(20); // #endif radiosocketdata.socket_port = port; radiosocketdata.socket_addr = address; radiosocketdata.socket_msg_len = msglength; radiosocketdata.socket_msg = msg; postTask(send_task, 9); sleepThread(20); restoreRadioState(); return; }
void WorkerGlobalScope::close() { if (m_closing) return; // Let current script run to completion but prevent future script evaluations. // After m_closing is set, all the tasks in the queue continue to be fetched but only // tasks with isCleanupTask()==true will be executed. m_closing = true; postTask({ ScriptExecutionContext::Task::CleanupTask, [] (ScriptExecutionContext& context) { ASSERT_WITH_SECURITY_IMPLICATION(is<WorkerGlobalScope>(context)); WorkerGlobalScope& workerGlobalScope = downcast<WorkerGlobalScope>(context); // Notify parent that this context is closed. Parent is responsible for calling WorkerThread::stop(). workerGlobalScope.thread().workerReportingProxy().workerGlobalScopeClosed(); } }); }
inline result_t TimerM_Clock_fire(void) { { _atomic_t _atomic = _atomic_start(); { if (TimerM_interval_outstanding == 0) { postTask(TimerM_HandleFire,7); } else { } ; TimerM_interval_outstanding += TimerM_Clock_getInterval() + 1; } _atomic_end(_atomic); } return SUCCESS; }
//Now this OS has a new packet, needs to deliver it to the correct thread for processing, and return the packet as soon as possible Radio_MsgPtr Standard_Receive_Packet(uint16_t port, Radio_MsgPtr packet){ uint8_t i; for (i=0;i<RECEIVE_HANDLE_NUM;i++) { if ((receivehandles[i].port == port)&&(receivehandles[i].handlevalid == 1)) { uint8_t temp; uint8_t j; uint8_t *buf; buf = (uint8_t*)receivehandles[i].data; temp = ( packet->length > (receivehandles[i].maxLength)? (receivehandles[i].maxLength): packet->length); for (j=0;j<temp; j++) { *buf = packet->data[j]; buf++; } if (receivehandles[i].packetinfo != NULL) { buf = (uint8_t*)receivehandles[i].packetinfo; *buf = packet->strength; buf++; *buf = packet->lqi; } if (receivehandles[i].handlefunc != NULL) postTask(receivehandles[i].handlefunc, 6); //if (*(receivehandles[i].dataReady) == 0) *(receivehandles[i].dataReady) = temp; return packet; } } return packet; }
void ScriptExecutionContext::processMessagePortMessagesSoon() { postTask(ProcessMessagesSoonTask::create()); }
void IDBServer::postDatabaseTask(CrossThreadTask&& task) { postTask(WTFMove(task)); }
void ScriptExecutionContext::processMessagePortMessagesSoon() { postTask([] (ScriptExecutionContext& context) { context.dispatchMessagePortEvents(); }); }
void ExecutionContext::postTask(const WebTraceLocation& location, std::unique_ptr<ExecutionContextTask> task, const String& taskNameForInstrumentation) { postTask(TaskType::Unspecified, location, std::move(task), taskNameForInstrumentation); }
//This function is called from the particular implementation! //This function also contains platform related defintions //0, 1, 2, AND 10, 11 are reserved. User is suggested to start with id 20. inline result_t GenericTimerFired(uint8_t id) { unsigned char result; //0, 1, 2 for threads switch (id) { case 0: ServiceTimerFired(0); break; case 1: ServiceTimerFired(1); break; case 2: ServiceTimerFired(2); break; case 3: ServiceTimerFired(3); break; case 4: ServiceTimerFired(4); break; case 5: ServiceTimerFired(5); break; case 6: ServiceTimerFired(6); break; case 7: ServiceTimerFired(7); break; case 9: #ifdef PLATFORM_CPU_MEASURE cpucounter_history[loop++] = cpucounter; cpucounter = 0; if (loop == 20) loop = 0; #endif break; #if defined(PLATFORM_AVR) && defined(RADIO_CC2420) case 10: hplcc2420interruptm_FIFOTimer_fired(); break; case 11: hplcc2420interruptm_CCATimer_fired(); break; #endif case 12: #ifdef ENERGY_SHARE_SCHEDULING {energy_manager_increase_round(); postTask(thread_task, 9); } #endif break; case 13: #ifdef TRACE_MEMORY_CONTENTS memoryReportTimerFired(); #endif break; case 14: #ifdef TRACE_ENABLE reportTrace(); #endif #ifdef BASE_MODE restoreRadioState(); #endif break; case 15: break; case 16: #ifdef TRACE_MEMORY_CONTENTS AMStandard_releaseLock(); lib_radio_set_channel(21); #endif break; default: timercallbackinvoke(id); result = SUCCESS; } return SUCCESS; }
void ExecutionContext::postSuspendableTask(PassOwnPtr<SuspendableTask> task) { m_suspendedTasks.append(task); if (!m_activeDOMObjectsAreSuspended) postTask(FROM_HERE, createSameThreadTask(&ExecutionContext::runSuspendableTasks, this)); }