コード例 #1
0
ファイル: memory.cpp プロジェクト: alivesay/emdb
static void scan (void *ctx, void *user_ctx, void (*dataHandler)(void *, uint8_t *, Entry *), void (*endHandler)(void *), void (*errorHandler)(void *, uint8_t *)) {
  MemoryCtx *context = (MemoryCtx *) ctx;
  MemoryKey *current;

  current = context->head;
  while (current != NULL) {
    dataHandler(user_ctx, current->key->key, emdb_copy_entry(current->entry));

    current = current->next;
  }

  endHandler(user_ctx);
}
コード例 #2
0
ファイル: utilsunx.cpp プロジェクト: ahlekoofe/gamekit
int wxAppTraits::WaitForChild(wxExecuteData& execData)
{
    if ( !(execData.flags & wxEXEC_SYNC) )
    {
        // asynchronous execution: just launch the process and return,
        // endProcData will be destroyed when it terminates (currently we leak
        // it if the process doesn't terminate before we do and this should be
        // fixed but it's not a real leak so it's not really very high
        // priority)
        wxEndProcessData *endProcData = new wxEndProcessData;
        endProcData->process = execData.process;
        endProcData->pid = execData.pid;
        endProcData->tag = AddProcessCallback
                           (
                               endProcData,
                               execData.GetEndProcReadFD()
                           );
        endProcData->async = true;

        return execData.pid;
    }
    //else: synchronous execution case

#if HAS_PIPE_INPUT_STREAM && wxUSE_SOCKETS
    wxProcess * const process = execData.process;
    if ( process && process->IsRedirected() )
    {
        // we can't simply block waiting for the child to terminate as we would
        // dead lock if it writes more than the pipe buffer size (typically
        // 4KB) bytes of output -- it would then block waiting for us to read
        // the data while we'd block waiting for it to terminate
        //
        // so multiplex here waiting for any input from the child or closure of
        // the pipe used to indicate its termination
        wxSelectDispatcher disp;

        wxEndHandler endHandler(disp, execData.GetEndProcReadFD());

        wxRedirectedIOHandler outHandler(disp, execData.fdOut, execData.bufOut),
                              errHandler(disp, execData.fdErr, execData.bufErr);

        while ( !endHandler.Terminated() )
        {
            disp.Dispatch();
        }
    }
    //else: no IO redirection, just block waiting for the child to exit
#endif // HAS_PIPE_INPUT_STREAM

    return DoWaitForChild(execData.pid);
}