当前位置: 首页>>代码示例>>C++>>正文


C++ Dispatch函数代码示例

本文整理汇总了C++中Dispatch函数的典型用法代码示例。如果您正苦于以下问题:C++ Dispatch函数的具体用法?C++ Dispatch怎么用?C++ Dispatch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Dispatch函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ref

void
BenchmarkPlayback::InputExhausted()
{
  RefPtr<Benchmark> ref(mMainThreadState);
  Dispatch(NS_NewRunnableFunction([this, ref]() {
    MOZ_ASSERT(OnThread());
    if (mFinished || mSampleIndex >= mSamples.Length()) {
      return;
    }
    mDecoder->Input(mSamples[mSampleIndex]);
    mSampleIndex++;
    if (mSampleIndex == mSamples.Length()) {
      if (ref->mParameters.mStopAtFrame) {
        mSampleIndex = 0;
      } else {
        mDecoder->Drain();
      }
    }
  }));
}
开发者ID:cbradley857,项目名称:gecko-dev,代码行数:20,代码来源:Benchmark.cpp

示例2: Monitor_Start

void Monitor_Start(RingBuffer *inputBuffer)
{
    dGuard(inputBuffer == NULL);

    OpenConsole();
    PrintLogo(Console);

    while (1)
    {
        uint16_t read = ReadLineInto(inputBuffer);
        StreamWriter_WriteLine(Console, inputBuffer->Buffer, read);

        if (!Dispatch(inputBuffer, Console)) break;
    }

    StreamWriter_WriteLine(Console, "Bye.", 4);

    Stream_Close(Console);
    Console = NULL;
}
开发者ID:obiwanjacobi,项目名称:Zalt,代码行数:20,代码来源:Monitor.c

示例3: Decode

int Decode(int index, uint8_t bytes[])
{
	Instruction instruction = DecodeInstruction(bytes[index]);
	AddressingMode addressingMode = DecodeAddressingMode(bytes[index]);
	
	/*
	* Exceptions:
	*    STX:
	*        ZeroPageX -> ZeroPageY
	*    LDX:
	*        ZeroPageX -> ZeroPageY
	*        AbsoluteX -> AbsoluteY
	*/
	if ((instruction == STX || instruction == LDX) && addressingMode == ZeroPageX)
		addressingMode = ZeroPageY;
	if (instruction == LDX && addressingMode == AbsoluteX)
		addressingMode = AbsoluteY;

	Dispatch(instruction, addressingMode, index, bytes);
	return FindInstructionLength(addressingMode);
}
开发者ID:Charile1,项目名称:6502emu,代码行数:21,代码来源:decoder.cpp

示例4: MOZ_ASSERT

void
BenchmarkPlayback::InitDecoder(TrackInfo&& aInfo)
{
  MOZ_ASSERT(OnThread());

  RefPtr<PDMFactory> platform = new PDMFactory();
  mDecoder = platform->CreateDecoder(aInfo, mDecoderTaskQueue, this);
  if (!mDecoder) {
    MainThreadShutdown();
    return;
  }
  RefPtr<Benchmark> ref(mMainThreadState);
  mDecoder->Init()->Then(
    ref->Thread(), __func__,
    [this, ref](TrackInfo::TrackType aTrackType) {
      Dispatch(NS_NewRunnableFunction([this, ref]() { InputExhausted(); }));
    },
    [this, ref](MediaDataDecoder::DecoderFailureReason aReason) {
      MainThreadShutdown();
    });
}
开发者ID:cbradley857,项目名称:gecko-dev,代码行数:21,代码来源:Benchmark.cpp

示例5: Dispatch

void VSTPlugin::Create(VSTPlugin *plug)
{
	h_dll=plug->h_dll;
	_pEffect=plug->_pEffect;
	_pEffect->user=this;
	Dispatch( effMainsChanged,  0, 1, NULL, 0.0f);
//	strcpy(_editName,plug->_editName); On current implementation, this replaces the right one. 
	strcpy(_sProductName,plug->_sProductName);
	strcpy(_sVendorName,plug->_sVendorName);
	
	_sDllName = new char[strlen(plug->_sDllName)+1];
	strcpy(_sDllName,plug->_sDllName);

	_isSynth=plug->_isSynth;
	_version=plug->_version;

	plug->instantiated=false;	// We are "stoling" the plugin from the "plug" object so this
								// is just a "trick" so that when destructing the "plug", it
								// doesn't unload the Dll.
	instantiated=true;
}
开发者ID:Angeldude,项目名称:pd,代码行数:21,代码来源:VstHost.cpp

示例6: LOG

void
CacheStorageService::OnMemoryConsumptionChange(CacheMemoryConsumer* aConsumer,
                                               uint32_t aCurrentMemoryConsumption)
{
  LOG(("CacheStorageService::OnMemoryConsumptionChange [consumer=%p, size=%u]",
    aConsumer, aCurrentMemoryConsumption));

  uint32_t savedMemorySize = aConsumer->mReportedMemoryConsumption;
  if (savedMemorySize == aCurrentMemoryConsumption)
    return;

  // Exchange saved size with current one.
  aConsumer->mReportedMemoryConsumption = aCurrentMemoryConsumption;

  mMemorySize -= savedMemorySize;
  mMemorySize += aCurrentMemoryConsumption;

  LOG(("  mMemorySize=%u (+%u,-%u)", uint32_t(mMemorySize), aCurrentMemoryConsumption, savedMemorySize));

  // Bypass purging when memory has not grew up significantly
  if (aCurrentMemoryConsumption <= savedMemorySize)
    return;

  if (mPurging) {
    LOG(("  already purging"));
    return;
  }

  if (mMemorySize <= CacheObserver::MemoryLimit())
    return;

  // Throw the oldest data or whole entries away when over certain limits
  mPurging = true;

  // Must always dipatch, since this can be called under e.g. a CacheFile's lock.
  nsCOMPtr<nsIRunnable> event =
    NS_NewRunnableMethod(this, &CacheStorageService::PurgeOverMemoryLimit);

  Dispatch(event);
}
开发者ID:at13,项目名称:mozilla-central,代码行数:40,代码来源:CacheStorageService.cpp

示例7: ProcessEvents

    bool ProcessEvents()
    {
        // process pending wx events first as they correspond to low-level events
        // which happened before, i.e. typically pending events were queued by a
        // previous call to Dispatch() and if we didn't process them now the next
        // call to it might enqueue them again (as happens with e.g. socket events
        // which would be generated as long as there is input available on socket
        // and this input is only removed from it when pending event handlers are
        // executed)
        if( wxTheApp )
        {
            wxTheApp->ProcessPendingEvents();

            // One of the pending event handlers could have decided to exit the
            // loop so check for the flag before trying to dispatch more events
            // (which could block indefinitely if no more are coming).
            if( m_shouldExit )
                return false;
        }

        return Dispatch();
    }
开发者ID:BTR1,项目名称:kicad-source-mirror,代码行数:22,代码来源:dialog_shim.cpp

示例8: ref

void
BenchmarkPlayback::Output(MediaData* aData)
{
  RefPtr<Benchmark> ref(mMainThreadState);
  Dispatch(NS_NewRunnableFunction([this, ref]() {
    mFrameCount++;
    if (mFrameCount == ref->mParameters.mStartupFrame) {
      mDecodeStartTime = TimeStamp::Now();
    }
    int32_t frames = mFrameCount - ref->mParameters.mStartupFrame;
    TimeDuration elapsedTime = TimeStamp::Now() - mDecodeStartTime;
    if (!mFinished &&
        (frames == ref->mParameters.mFramesToMeasure ||
         elapsedTime >= ref->mParameters.mTimeout)) {
      uint32_t decodeFps = frames / elapsedTime.ToSeconds();
      MainThreadShutdown();
      ref->Dispatch(NS_NewRunnableFunction([ref, decodeFps]() {
        ref->ReturnResult(decodeFps);
      }));
    }
  }));
}
开发者ID:devtools-html,项目名称:gecko-dev,代码行数:22,代码来源:Benchmark.cpp

示例9: SOCKET_LOG

nsresult
nsSocketTransportService::DetachSocket(SocketContext *listHead, SocketContext *sock)
{
    SOCKET_LOG(("nsSocketTransportService::DetachSocket [handler=%p]\n", sock->mHandler));
    MOZ_ASSERT((listHead == mActiveList) || (listHead == mIdleList),
               "DetachSocket invalid head");

    // inform the handler that this socket is going away
    sock->mHandler->OnSocketDetached(sock->mFD);
    mSentBytesCount += sock->mHandler->ByteCountSent();
    mReceivedBytesCount += sock->mHandler->ByteCountReceived();

    // cleanup
    sock->mFD = nullptr;
    NS_RELEASE(sock->mHandler);

    if (listHead == mActiveList)
        RemoveFromPollList(sock);
    else
        RemoveFromIdleList(sock);

    // NOTE: sock is now an invalid pointer
    
    //
    // notify the first element on the pending socket queue...
    //
    nsCOMPtr<nsIRunnable> event;
    LinkedRunnableEvent *runnable = mPendingSocketQueue.getFirst();
    if (runnable) {
        event = runnable->TakeEvent();
        runnable->remove();
        delete runnable;
    }
    if (event) {
        // move event from pending queue to dispatch queue
        return Dispatch(event, NS_DISPATCH_NORMAL);
    }
    return NS_OK;
}
开发者ID:zbraniecki,项目名称:gecko-dev,代码行数:39,代码来源:nsSocketTransportService2.cpp

示例10: sizeof

	void ConnectionHandler::DispatchIfCan() {
		if (reading_status_ == ReadingStatus::Length && socket_buffer_.used() >= sizeof(UInt32)) {
			UInt32Bytes length{};
			socket_buffer_.read(length.bytes, sizeof(UInt32));

			current_message_length = length.number;
			// set reading status to next
			reading_status_ = ReadingStatus::OpCode;
		}

		if (reading_status_ == ReadingStatus::OpCode && socket_buffer_.used() >= sizeof(UInt32)) {
			UInt32Bytes opcode{};
			socket_buffer_.read(opcode.bytes, sizeof(UInt32));

			// initialize current message with the opcode
			current_message_ = Message{opcode.number};
			// set reading status to data
			reading_status_ = ReadingStatus::Data;
		}

		if (reading_status_ == ReadingStatus::Data && socket_buffer_.used() >= current_message_length) {
			// initialize the vector for the data
			current_message_.data_vector().clear();
			current_message_.data_vector().resize(current_message_length);

			socket_buffer_.read(current_message_.data(), current_message_length);

			// dispatch message
			Dispatch(current_message_);

			// set reading status back to length
			reading_status_ = ReadingStatus::Length;
			// if there is data in the buffer and we read the whole
			// packet, launch socket readable once more
			if (socket_buffer_.used() > sizeof(UInt32)) {
				DispatchIfCan();
			}
		}
	}
开发者ID:BeeeOn,项目名称:gateway-man-core,代码行数:39,代码来源:connection_handler.cpp

示例11: ASSERT_OWNING_THREAD

void
LazyIdleThread::EnableIdleTimeout()
{
  ASSERT_OWNING_THREAD();
  if (mIdleTimeoutEnabled) {
    return;
  }
  mIdleTimeoutEnabled = true;

  {
    MutexAutoLock lock(mMutex);

    MOZ_ASSERT(mPendingEventCount, "Mismatched calls to observer methods!");
    --mPendingEventCount;
  }

  if (mThread) {
    nsCOMPtr<nsIRunnable> runnable(new nsRunnable());
    if (NS_FAILED(Dispatch(runnable, NS_DISPATCH_NORMAL))) {
      NS_WARNING("Failed to dispatch!");
    }
  }
}
开发者ID:Tripleman,项目名称:mozilla-central,代码行数:23,代码来源:LazyIdleThread.cpp

示例12: cairo_ps_surface_create

void Shape::Render(const char *path){
  if(geom_ == NULL) return;
  cairo_surface_t *surface = cairo_ps_surface_create(path, width_, height_);
  if(cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS) {
    std::cout << cairo_status_to_string(cairo_surface_status(surface)) << std::endl;
    exit(1);
    return;
  }

  ctx_ = cairo_create(surface);

  OGREnvelope env;
  geom_->getEnvelope(&env);
  cairo_matrix_t mat;
  matrix_init(&mat, width_, height_, &env);
  cairo_set_matrix(ctx_, &mat);

  Dispatch(geom_);

  cairo_show_page(ctx_);
  cairo_destroy(ctx_);
  cairo_surface_destroy(surface);
}
开发者ID:PoNote,项目名称:stateface,代码行数:23,代码来源:shape.cpp

示例13: Dispatch

//*=================================================================================
//*原型: void ProcessRequest(SOCKET hSocket)
//*功能: 处理客户机的请求
//*参数: 无
//*返回: 无
//*说明: 先读入包头, 再读包数据, 然后再处理请求
//*=================================================================================
void TSmartOutThread::ProcessRequest(SOCKET hSocket, SOCKADDR_IN *psockAddr)
{
	TSmartPacket Packet;

	try
	{
		if( ReadRequestPacket(hSocket, Packet) )
		{
			if( CheckPacket(psockAddr, Packet) )
			{
				Dispatch(hSocket, psockAddr, Packet);
			}
		}
	}
	catch(TException& e)
	{
		WriteLog(e.GetText());
	}
	catch(...)
	{
		WriteLog("客户服务线程有未知异常!");
	}
}
开发者ID:Codiscope-Research,项目名称:ykt4sungard,代码行数:30,代码来源:TSmartOutThread.cpp

示例14: while

bool wxGUIEventLoop::YieldFor(long eventsToProcess)
{
#if wxUSE_THREADS
    if ( !wxThread::IsMain() )
        return true; // can't process events from other threads
#endif // wxUSE_THREADS

    m_isInsideYield = true;
    m_eventsToProcessInsideYield = eventsToProcess;

#if wxUSE_LOG
    wxLog::Suspend();
#endif // wxUSE_LOG

    // TODO: implement event filtering using the eventsToProcess mask

    // process all pending events:
    while ( Pending() )
        Dispatch();

    // handle timers, sockets etc.
    OnNextIteration();

    // it's necessary to call ProcessIdle() to update the frames sizes which
    // might have been changed (it also will update other things set from
    // OnUpdateUI() which is a nice (and desired) side effect)
    while ( ProcessIdle() ) {}

#if wxUSE_LOG
    wxLog::Resume();
#endif // wxUSE_LOG

    m_isInsideYield = false;

    return true;
}
开发者ID:beanhome,项目名称:dev,代码行数:36,代码来源:evtloop.cpp

示例15: doSchedule

/* doSchedule() will do a Task Switch to a high priority task
 * in ready state.It don't care wether OSCurTask are
 * Preemptable or not,or INVALID_TASK.
 * Note OSCurTsk also may be the highest priority Task in READY state. 
 * in ready or running state*/
void doSchedule(void)
{
    /* The Situation that when the SEVERAL_TASKS_PER_PRIORITY Policy was adopted,
     * there may be a task or more with the same xPriority as OSCurTsk in the
     * ready state*/
    if(OSCurTsk == OSHighRdyTsk)
    {   /* higher priority task in ready or running state */
        /* Search the table map to find  OSHighPriority*/
        OS_ENTER_CRITICAL();
#if (cfgOS_TASK_PER_PRIORITY == SEVERAL_TASKS_PER_PRIORITY)
        if(listTskRdyIsEmpty(OSCurTcb->xPriority))
        { /* if OSTskRdyListHead[xPriority] is Empty, */
#endif    /* Find out an Runnable Task */
            OSHighRdyPrio = tableRdyMapFindHighPriority();
#if (cfgOS_TASK_PER_PRIORITY == SEVERAL_TASKS_PER_PRIORITY)
        } /* if OSTcbRdyGrpList[xPriority] is not Empty, */
#endif    /* make the head task runnable */
        /* Get The Tcb with the highest Priority*/
        OSHighRdyTsk = listGetRdyTsk(OSHighRdyPrio);
        OSHighRdyTcb = &OSTcbTable[OSHighRdyTsk];
        OS_EXIT_CRITICAL();
    }
    Dispatch();
}
开发者ID:1984c,项目名称:GaInOS,代码行数:29,代码来源:Task.c


注:本文中的Dispatch函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。