Esempio n. 1
0
/* Think hook of the database instance.
 * In case the database connection was established or failed for the first time the connection callbacks are being run.
 * Takes all the queries from the finished queries queue and runs the callback for them.
 */
void Database::think(lua_State* state)
{
	if (m_connectionDone && !dbCallbackRan)
	{
		if (m_success)
		{
			runCallback(state, "onConnected");
		}
		else
		{
			runCallback(state, "onConnectionFailed", "s", m_connection_err.c_str());
		}
		this->unreference(state);
		dbCallbackRan = true;
	}
	//Needs to lock for condition check to prevent race conditions
	std::unique_lock<std::mutex> lock(m_finishedQueueMutex);
	while (!finishedQueries.empty())
	{
		std::shared_ptr<IQuery> curquery = finishedQueries.front();
		finishedQueries.pop_front();
		//Unlocking here because the lock isn't needed for the callbacks
		//Allows the database thread to add more finished queries
		lock.unlock();
		curquery->doCallback(state);
		curquery->canbedestroyed = true;
		curquery->unreference(state);
		lock.lock();
	}
}
Esempio n. 2
0
JNIEXPORT jint JNICALL Java_org_apache_harmony_test_func_reg_vm_btest3010_Btest3010_runCallBack  (JNIEnv *, jclass) {

    fprintf(stderr,"enter Java_CallBack_runCallBack\n");
    fflush(stdout);

    runCallback(100, 1, 1, 2);
    runCallback(100, 2, 3, 4);
    runCallback(100, 3, 5, 6);
    runCallback(100, 4, 7, 8);

    fprintf(stderr,"exit Java_CallBack_runCallBack\n");
    fflush(stdout);

    return 4;
}
Esempio n. 3
0
void AsioSession::onIOWaitEnter() {
  runCallback(
    m_onIOWaitEnterCallback,
    empty_array(),
    "WaitHandle::onIOWaitEnter"
  );
}
Esempio n. 4
0
void AsioSession::onJoin(c_WaitHandle* waitHandle) {
  runCallback(
    m_onJoinCallback,
    make_packed_array(waitHandle),
    "WaitHandle::onJoin"
  );
}
Esempio n. 5
0
void AsioSession::onSleepCreate(c_SleepWaitHandle* waitHandle) {
  runCallback(
    m_onSleepCreateCallback,
    make_packed_array(waitHandle),
    "SleepWaitHandle::onCreate"
  );
}
Esempio n. 6
0
void AsioSession::onSleepSuccess(c_SleepWaitHandle* waitHandle) {
  runCallback(
    m_onSleepSuccessCallback,
    make_packed_array(waitHandle),
    "SleepWaitHandle::onSuccess"
  );
}
void ScriptCustomElementDefinition::runDisconnectedCallback(Element* element) {
  if (!m_scriptState->contextIsValid())
    return;
  ScriptState::Scope scope(m_scriptState.get());
  v8::Isolate* isolate = m_scriptState->isolate();
  runCallback(m_disconnectedCallback.newLocal(isolate), element);
}
int Test::callbackTest()
{
    DebugMessage("Running callback...\n");
    runCallback("onCallback", "si", "test", (int)m_currentTime);
    DebugMessage("...Done\n");
    return 0;
}
Esempio n. 9
0
void AsioSession::onJoin(c_WaitHandle* waitHandle) {
  runCallback(
    m_onJoinCallback,
    Array::Create(waitHandle),
    "WaitHandle::onJoin"
  );
}
Esempio n. 10
0
void AsioSession::onIOWaitExit() {
  runCallback(
    m_onIOWaitExitCallback,
    empty_array(),
    "WaitHandle::onIOWaitExit"
  );
}
Esempio n. 11
0
void AsioSession::onExternalThreadEventCreate(
  c_ExternalThreadEventWaitHandle* waitHandle
) {
  runCallback(
    m_onExternalThreadEventCreateCallback,
    make_packed_array(waitHandle),
    "ExternalThreadEventWaitHandle::onCreate"
  );
}
Esempio n. 12
0
void AsioSession::onResumableCreate(
    c_ResumableWaitHandle* resumable,
    c_WaitableWaitHandle* child
) {
    runCallback(m_onResumableCreate,
                make_packed_array(resumable, child),
                "ResumableWaitHandle::onCreate"
               );
}
Esempio n. 13
0
void AsioSession::onGenVectorCreate(
  c_GenVectorWaitHandle* waitHandle,
  const Variant& dependencies
) {
  runCallback(
    m_onGenVectorCreateCallback,
    make_packed_array(waitHandle, dependencies),
    "GenVectorWaitHandle::onCreate"
  );
}
Esempio n. 14
0
void AsioSession::onAwaitAllCreate(
  c_AwaitAllWaitHandle* waitHandle,
  const Variant &dependencies
) {
  runCallback(
    m_onAwaitAllCreateCallback,
    make_packed_array(waitHandle, dependencies),
    "AwaitAllWaitHandle::onCreate"
  );
}
Esempio n. 15
0
void AsioSession::onResumableFail(
  c_ResumableWaitHandle* resumable,
  const Object& exception
) {
  runCallback(
    m_onResumableFailCallback,
    make_packed_array(resumable, exception),
    "ResumableWaitHandle::onFail"
  );
}
Esempio n. 16
0
void AsioSession::onResumableAwait(
  c_ResumableWaitHandle* resumable,
  c_WaitableWaitHandle* child
) {
  runCallback(
    m_onResumableAwaitCallback,
    make_packed_array(resumable, child),
    "ResumableWaitHandle::onAwait"
  );
}
Esempio n. 17
0
void AsioSession::onConditionCreate(
  c_ConditionWaitHandle* waitHandle,
  c_WaitableWaitHandle* child
) {
  runCallback(
    m_onConditionCreateCallback,
    make_packed_array(waitHandle, child),
    "ConditionWaitHandle::onCreate"
  );
}
void Database::poll()
{
  checkQueries();

  if (!m_connectionThread)
    return;

  Thread::EventData event;
  if (!m_connectionThread->getEvent(event))
    return;

  if (event.id == ConnectThread::CONNECTION_FINISHED)
  {
    if (m_connectionThread->wasSuccessful())
      runCallback("onConnected");
    else
      runCallback("onConnectionFailed", "s", m_connectionThread->error().c_str() );
  }
}
Esempio n. 19
0
void AsioSession::onExternalThreadEventFail(
  c_ExternalThreadEventWaitHandle* waitHandle,
  const Object& exception
) {
  runCallback(
    m_onExternalThreadEventFailCallback,
    make_packed_array(waitHandle, exception),
    "ExternalThreadEventWaitHandle::onFail"
  );
}
Esempio n. 20
0
void AsioSession::onResumableSuccess(
  c_ResumableWaitHandle* resumable,
  const Variant& result
) {
  runCallback(
    m_onResumableSuccessCallback,
    make_packed_array(resumable, result),
    "ResumableWaitHandle::onSuccess"
  );
}
Esempio n. 21
0
void AsioSession::onExternalThreadEventSuccess(
  c_ExternalThreadEventWaitHandle* waitHandle,
  const Variant& result
) {
  runCallback(
    m_onExternalThreadEventSuccessCallback,
    make_packed_array(waitHandle, result),
    "ExternalThreadEventWaitHandle::onSuccess"
  );
}
Esempio n. 22
0
void ThreadPoolTaskExecutor::scheduleIntoPool_inlock(WorkQueue* fromQueue,
                                                     const WorkQueue::iterator& begin,
                                                     const WorkQueue::iterator& end) {
    dassert(fromQueue != &_poolInProgressQueue);
    std::for_each(
        begin,
        end,
        [this](const std::shared_ptr<CallbackState>& cbState) {
            fassert(28735, _pool->schedule([this, cbState] { runCallback(std::move(cbState)); }));
        });
    _poolInProgressQueue.splice(_poolInProgressQueue.end(), *fromQueue, begin, end);
    _net->signalWorkAvailable();
}
void ScriptCustomElementDefinition::runAdoptedCallback(Element* element,
                                                       Document* oldOwner,
                                                       Document* newOwner) {
  if (!m_scriptState->contextIsValid())
    return;
  ScriptState::Scope scope(m_scriptState.get());
  v8::Isolate* isolate = m_scriptState->isolate();
  v8::Local<v8::Value> argv[] = {
      toV8(oldOwner, m_scriptState->context()->Global(), isolate),
      toV8(newOwner, m_scriptState->context()->Global(), isolate)};
  runCallback(m_adoptedCallback.newLocal(isolate), element,
              WTF_ARRAY_LENGTH(argv), argv);
}
void ScriptedIdleTaskController::callbackFired(CallbackId id, double deadlineSeconds, IdleDeadline::CallbackType callbackType)
{
    if (!m_callbacks.contains(id))
        return;

    if (m_suspended) {
        if (callbackType == IdleDeadline::CallbackType::CalledByTimeout) {
            // Queue for execution when we are resumed.
            m_pendingTimeouts.append(id);
        }
        // Just drop callbacks called while suspended, these will be reposted on the idle task queue when we are resumed.
        return;
    }

    runCallback(id, deadlineSeconds, callbackType);
}
void ScriptedIdleTaskController::resume()
{
    ASSERT(m_suspended);
    m_suspended = false;

    // Run any pending timeouts.
    Vector<CallbackId> pendingTimeouts;
    m_pendingTimeouts.swap(pendingTimeouts);
    for (auto& id : pendingTimeouts)
        runCallback(id, monotonicallyIncreasingTime(), IdleDeadline::CallbackType::CalledByTimeout);

    // Repost idle tasks for any remaining callbacks.
    for (auto& callback : m_callbacks) {
        RefPtr<internal::IdleRequestCallbackWrapper> callbackWrapper = internal::IdleRequestCallbackWrapper::create(callback.key, this);
        m_scheduler->postIdleTask(BLINK_FROM_HERE, WTF::bind<double>(&internal::IdleRequestCallbackWrapper::idleTaskFired, callbackWrapper));
    }
}
void ScriptCustomElementDefinition::runAttributeChangedCallback(
    Element* element,
    const QualifiedName& name,
    const AtomicString& oldValue,
    const AtomicString& newValue) {
  if (!m_scriptState->contextIsValid())
    return;
  ScriptState::Scope scope(m_scriptState.get());
  v8::Isolate* isolate = m_scriptState->isolate();
  v8::Local<v8::Value> argv[] = {
      v8String(isolate, name.localName()), v8StringOrNull(isolate, oldValue),
      v8StringOrNull(isolate, newValue),
      v8StringOrNull(isolate, name.namespaceURI()),
  };
  runCallback(m_attributeChangedCallback.newLocal(isolate), element,
              WTF_ARRAY_LENGTH(argv), argv);
}
Esempio n. 27
0
void CallbackHuman::talk()
{
    runCallback({{"THIS", this}});
}