void MsgProgressGrow() { if (m_stopMsgGrow) return; PutMsg(this, &Test::MsgProgressGrow); PutMsg(this, &Test::MsgProgressGrow); }
void tdev_BeginIO(TestDevBase *TestDevBase, struct IORequest *ioreq) { ioreq->io_Error = 0; // First we try to do everything "QUICK" = Synchronous if (ioreq->io_Flags & IOF_QUICK) { switch(ioreq->io_Command) { // These Commands cant be done QUICK (async) case CMD_READ: case CMD_WRITE: PutMsg(TestDevBase->TaskPort, &ioreq->io_Message); ioreq->io_Flags &= ~IOF_QUICK; return; default: break; } // All the rest can be done Sync tdev_PerformIO(TestDevBase, ioreq); return; } else { PutMsg(TestDevBase->TaskPort, &ioreq->io_Message); ioreq->io_Flags &= ~IOF_QUICK; return; } }
void cd_beginio (void *ioreq) { struct FSReq *fsreq = ioreq; struct CDSB *cdsb; struct CDFilp *filp; fsreq->flags &= ~IOF_QUICK; switch (fsreq->cmd) { case FS_CMD_OPEN: case FS_CMD_OPENDIR: case FS_CMD_STAT: case FS_CMD_MKDIR: case FS_CMD_UNLINK: case FS_CMD_RMDIR: case FS_CMD_FORMAT: case FS_CMD_RENAME: case FS_CMD_INHIBIT: case FS_CMD_UNINHIBIT: cdsb = fsreq->unitp; PutMsg (cdsb->msgport, &fsreq->msg); break; case FS_CMD_CLOSE: case FS_CMD_CLOSEDIR: case FS_CMD_DUP: case FS_CMD_READ: case FS_CMD_WRITE: case FS_CMD_LSEEK: case FS_CMD_READDIR: case FS_CMD_REWINDDIR: case FS_CMD_ISATTY: case FS_CMD_CHMOD: case FS_CMD_CHOWN: case FS_CMD_TRUNCATE: case FS_CMD_FSTAT: filp = fsreq->filp; cdsb = filp->cdsb; PutMsg (cdsb->msgport, &fsreq->msg); break; default: fsreq->flags |= IOF_QUICK; fsreq->rc = -1; fsreq->error = ENOSYS; } }
void DoDragFiles( HWND hwnd ) { BOOL fSuccess; PSZ pFiles[1]; PSZ pTargets[1]; pFiles[0] = szFilePath; pTargets[0] = NULL; if( !DrgDragFiles(hwnd, pFiles, NULL, pTargets, 1, hptrDrag, VK_BUTTON2, bSourceRender, 0L) ) PutMsg( 2, (ULONG)"DrgDragFiles failed", NULL, NULL ); else PutMsg( 2, (ULONG)"DrgDragFiles OK", NULL, NULL ); }
static void PrtMsg( int severity, int msgnum, va_list args1, va_list args2 ) /***************************************************************************/ { if( !banner_printed ) trademark(); if( FileInfo.file[ERR] == NULL ) OpenErrFile(); PutMsg( errout, severity, msgnum, args1 ); fflush( errout ); /* 27-feb-90 */ if( FileInfo.file[ERR] ) { //Errfile_Written = TRUE; PutMsg( FileInfo.file[ERR], severity, msgnum, args2 ); } }
int main(int argc, char *argv[]) { if (argc != 3) // Test for correct number of arguments DieWithUserMessage("Parameter(s)", "<Server Address/Name> [<Server Port/Service>]"); char *server = argv[1]; // First arg: server address/name char *service = argv[2]; // Create a connected TCP socket int sock = SetupTCPClientSocket(server, service); if (sock < 0) DieWithUserMessage("SetupTCPClientSocket() failed", "unable to connect"); FILE *str = fdopen(sock,"r+"); char buffer[MAXSTRINGLENGTH]; //while((scanf("%s",buffer) != EOF)){ while(gets(buffer) && strlen(buffer) != 0){ int sSize; int stringLen = strlen(buffer); // Determine input length if((sSize = PutMsg(buffer, stringLen, str)) < 0) DieWithSystemMessage("PutMsg() failed"); //printf("Sending %d-byte..\n",sSize); /* GetNextMsg(str,buffer,MAXSTRINGLENGTH); printf("get echo\n"); printf("%s\n",buffer); */ memset(buffer,0,sizeof(buffer)); } fclose(str); printf("quit.\n"); return 0; }
// Send an IPC startup int ASM L_IPC_Startup( REG(a0, IPCData *ipc), REG(a1, APTR data), REG(a2, struct MsgPort *reply)) { struct MsgPort *port=0; IPCMessage startup; // If no message port supplied, create one if (!reply) port=reply=CreateMsgPort(); // Fill out startup message startup.msg.mn_ReplyPort=reply; startup.command=IPC_STARTUP; startup.flags=(ULONG)ipc; startup.data=data; // Send the startup message PutMsg(&ipc->proc->pr_MsgPort,(struct Message *)&startup); // Wait for reply back WaitPort(reply); GetMsg(reply); // Delete port if we created one if (port) DeleteMsgPort(port); // If there's no command port, report failure if (startup.command!=IPC_STARTUP) return 0; return 1; }
void SlowMsg() { Utils::TimerTicks t; t.Sleep(CPollInterval + CMaxLagValue * 3); PutMsg(this, &Test::SlowMsg); }
void RegisterARexxFunctionHost(int add) { struct RexxMsg *mess; struct MsgPort *rexxmastport; if(!(mess=(struct RexxMsg *)AllocMem(sizeof(struct RexxMsg), MEMF_CLEAR | MEMF_PUBLIC))) { cleanup(EXIT_ERROR, "Out of memory."); } mess->rm_Node.mn_Node.ln_Type = NT_MESSAGE; mess->rm_Node.mn_Length = sizeof(struct RexxMsg); mess->rm_Node.mn_ReplyPort=rexxport; mess->rm_Action = add ? RXADDFH : RXREMLIB; mess->rm_Args[0] = "NIKOMREXXHOST"; mess->rm_Args[1] = 0L; Forbid(); rexxmastport = (struct MsgPort *)FindPort("REXX"); if(rexxmastport) { PutMsg((struct MsgPort *)rexxmastport,(struct Message *)mess); } Permit(); if(rexxmastport == NULL) { FreeMem(mess, sizeof(struct RexxMsg)); if(add) { cleanup(EXIT_ERROR, "Can't find port 'REXX' (ARexx master server)"); } return; } WaitPort(rexxport); GetMsg(rexxport); FreeMem(mess, sizeof(struct RexxMsg)); }
ULONG TellWBTaskToCloseWindows(struct IntuitionBase *IntuitionBase) { DEBUG_WORKBENCH(dprintf("TellWBTaskToCloseWindows: currenttask <%s>\n", FindTask(NULL)->tc_Node.ln_Name)); if( GetPrivIBase(IntuitionBase)->WorkBenchMP != NULL ) { struct IntuiMessage *imsg; if ((imsg = AllocIntuiMessage(NULL))) { /* Setup our message */ imsg->ExecMessage.mn_ReplyPort = GetPrivIBase(IntuitionBase)->IntuiReplyPort; imsg->Class = IDCMP_WBENCHMESSAGE; imsg->Code = WBENCHCLOSE; DEBUG_WORKBENCH(dprintf("TellWBTaskToCloseWindows: Send Msg\n")); /* Sends it to the handler asynchron */ PutMsg( GetPrivIBase(IntuitionBase)->WorkBenchMP, &imsg->ExecMessage); DEBUG_WORKBENCH(dprintf("TellWBTaskToCloseWindows: done\n")); return(TRUE); } else { DEBUG_WORKBENCH(dprintf("TellWBTaskToCloseWindows: no memory\n")); } } else { DEBUG_WORKBENCH(dprintf("TellWBTaskToCloseWindows: no Workbench port\n")); } return(FALSE); }
AutotrainerSipCall::AutotrainerSipCall(iCore::MsgThread &thread, iLogW::ILogSessionCreator &logCreator, boost::function<void (T *)> deleter, Utils::SafeRef<IRemoteParticipant> remoteParticipant, const Commands &commands) : iCore::MsgObject(thread), m_timer(this, &T::OnTimeout), m_log(logCreator.CreateSession(CallName(), true)), m_infoTag(m_log->RegisterRecordKind(L"Info", true)), m_deleter(deleter), m_callDeleted(false), m_commands(commands), m_remoteParticipant(remoteParticipant) { // Incoming call ESS_ASSERT(!m_commands.empty()); if (m_log->LogActive(m_infoTag)) { *m_log << m_infoTag << "Created." << iLogW::EndRecord; } m_remoteParticipant->LinkUser(this); CreateMedia(); PutMsg(this, &T::OnCommand); }
void iomanager_beginio (void *ioreq) { struct IOMReq *iomreq = ioreq; iomreq->flags &= ~IOF_QUICK; PutMsg (iomanager_msgport, &iomreq->msg); }
void stop_engine(engine_t e) { assert(e); /* mutex_lock(e->mtx); e->status = 0; //强制唤醒所有等待在完成队列上的线程 struct block_queue *queue = 0; /*唤醒所有等待在完成队列的线程* / while(queue = LIST_POP(struct block_queue *,e->block_thread_queue)) { BLOCK_QUEUE_FORCE_WAKEUP(queue); } mutex_unlock(e->mtx); */ mutex_lock(e->mtx); e->status = 0; //强制唤醒所有等待在完成队列上的线程 MsgQueue_t msgQ = 0; /*唤醒所有等待在完成队列的线程*/ while(msgQ = LIST_POP(MsgQueue_t,e->block_thread_queue)) { //发送一个0消息 void *tmp = 0; PutMsg(msgQ,&tmp,sizeof(tmp)); } mutex_unlock(e->mtx); }
int dllKillLibrary(char *portname) { dll_tMessage msg,*reply; struct MsgPort *myport; struct MsgPort *dllport; bug("[DynLink] %s('%s')\n", __PRETTY_FUNCTION__, portname); if(!(myport=CreateMsgPort())) exit(0L); //Arghh bzero(&msg, sizeof(msg)); msg.dllMessageType=DLLMTYPE_Kill; msg.Message.mn_ReplyPort = myport; if((dllport=FindPort(portname))) { PutMsg(dllport, (struct Message *)&msg); /*WaitPort(myport);*/ while(!(reply=(dll_tMessage *)GetMsg(myport))) { Delay(2); if(FindPort(portname)!=dllport) break; } } DeleteMsgPort(myport); return (dllport?1:0); }
int put_event(engine_t e,st_io *io) { assert(e); assert(io); /* mutex_lock(e->mtx); struct block_queue *EventQ = LIST_POP(struct block_queue*,e->block_thread_queue); if(!EventQ) { //没有等待的线程,先缓冲事件 LIST_PUSH_BACK(e->buffering_event_queue,io); io = 0; } mutex_unlock(e->mtx); if(io) BLOCK_QUEUE_PUSH(EventQ,io); */ //printf("putevent\n"); mutex_lock(e->mtx); MsgQueue_t msgQ = LIST_POP(MsgQueue_t,e->block_thread_queue); if(!msgQ) { //没有等待的线程,先缓冲事件 LIST_PUSH_BACK(e->buffering_event_queue,io); io = 0; } mutex_unlock(e->mtx); if(io) PutMsg(msgQ,&io,sizeof(io)); return 0; }
/* * Start proxy thread */ static int start_proxy_thread (void) { int result = -1; struct MsgPort *replyport = CreateMsgPort(); struct Process *p; if (replyport) { p = myCreateNewProcTags (NP_Name, (ULONG) "E-UAE semaphore proxy", NP_Priority, 10, NP_StackSize, 2048, NP_Entry, (ULONG) proxy_thread_main, TAG_DONE); if (p) { /* Send startup message */ struct Message msg; msg.mn_ReplyPort = replyport; msg.mn_Length = sizeof msg; PutMsg (&p->pr_MsgPort, (struct Message*)&msg); WaitPort (replyport); proxy_thread = p; atexit (stop_proxy_thread); result = 0; } DeleteMsgPort (replyport); } return result; }
int uae_start_thread (void *(*f) (void *), void *arg, uae_thread_id *foo) { struct MsgPort *replyport = CreateMsgPort(); if (replyport) { *foo = (struct Task *)myCreateNewProcTags (NP_Output, Output (), NP_Input, Input (), NP_Name, (ULONG) "UAE thread", NP_CloseOutput, FALSE, NP_CloseInput, FALSE, NP_StackSize, 16384, NP_Entry, (ULONG) do_thread, TAG_DONE); if(*foo) { struct startupmsg msg; msg.msg.mn_ReplyPort = replyport; msg.msg.mn_Length = sizeof msg; msg.func = f; msg.arg = arg; PutMsg (&((struct Process*)*foo)->pr_MsgPort, (struct Message*)&msg); WaitPort (replyport); } DeleteMsgPort (replyport); } return *foo!=0; }
int main() { Port a; MCB m; word timeout = OneSec*5; word start, end; word e; a = NewPort(); forever { InitMCB(&m,MsgHdr_Flags_preserve,a,NullPort,1); /* IOCTimeout */ m.Timeout = timeout; start = _cputime(); /* times in centiseconds */ e = PutMsg(&m); end = _cputime(); if ((end - start) > ((timeout/10000) + 500) || (end - start) < 0) { printf("PutMsg TIMEOUT ERROR returned %lx - ", e); IOdebug("PutMsg TIMEOUT ERROR 500 != %x centisecs\n",end-start); } printf("Timeout in %ld centisecs\n",end-start); } }
void TcpSocketEmul::ConnectToHost(const Utils::HostInf &host) { m_connected = true; PutMsg(this, &T::OnConnectToHost, shared_ptr<Utils::HostInf>(new Utils::HostInf(host))); }
VOID __saveds PingFunc( VOID ) { struct MsgPort *ClientPort, *ReplyPort; struct Library *SysBase; BlankMsg PingMsg; SysBase = *( struct Library ** )4L; if( ReplyPort = CreateMsgPort()) { PingMsg.bm_Mess.mn_ReplyPort = ReplyPort; PingMsg.bm_Mess.mn_Length = sizeof( BlankMsg ); PingMsg.bm_Type = BM_PING; /* Stealthimania, to alleviate processing at the blanker */ PingMsg.bm_Mess.mn_Node.ln_Name = ( UBYTE * )( &Blanking ); for( ;; ) { if( SetSignal( 0L, SIGBREAKF_CTRL_C ) & SIGBREAKF_CTRL_C ) break; if( ClientPort = FindPort( "GarshneClient" )) { PingMsg.bm_Flags = 0L; PutMsg( ClientPort, ( struct Message * )( &PingMsg )); WaitPort( ReplyPort ); GetMsg( ReplyPort ); } } DeletePort( ReplyPort ); } }
static BOOL CmdRead(LIBBASETYPEPTR LIBBASE, struct IOSana2Req *request) { struct SiS900Unit *unit; struct Opener *opener; BOOL complete = FALSE; unit = (APTR)request->ios2_Req.io_Unit; D(bug("[%s]: S2CmdRead()\n", unit->sis900u_name)); if((unit->sis900u_ifflags & IFF_UP) != 0) { opener = request->ios2_BufferManagement; request->ios2_Req.io_Flags &= ~IOF_QUICK; PutMsg(&opener->read_port, (struct Message *)request); } else { request->ios2_Req.io_Error = S2ERR_OUTOFSERVICE; request->ios2_WireError = S2WERR_UNIT_OFFLINE; complete = TRUE; } /* Return */ return complete; }
void AXB_REG_FUNC DevBeginIO(AXB_REG(struct IOStdReq *ior,a1), AXB_REG(struct DevBase *db,a6)) { struct ExBase *eb = (struct ExBase *)db; D(("DevBeginIO\n")); ior->io_Error = 0; ior->io_Flags &= ~IOF_QUICK; switch(ior->io_Command) { case CMD_READ: case CMD_WRITE: /* forward message to worker process */ PutMsg(eb->eb_WorkerPort, &ior->io_Message); break; case CMD_RESET: case CMD_UPDATE: case CMD_CLEAR: case CMD_STOP: case CMD_START: case CMD_FLUSH: case CMD_INVALID: default: ior->io_Error = IOERR_NOCMD; ReplyMsg(&ior->io_Message); break; } }
void bounce(Port txport, Port rxport) { int i; MCB m; int start , end; unsigned int total; word e; byte *buf = (byte *)Malloc(msgsize); m.Data = buf; start = clock(); for( i = 1; i <= bounces ; i++ ) { InitMCB(&m,MsgHdr_Flags_preserve,txport,rxport,i); m.Timeout = OneSec*5; *(int *)&m |= msgsize; e = PutMsg(&m); m.MsgHdr.Dest = rxport; e=GetMsg(&m); } end = clock(); total=end-start; printf("%u microseconds for %u bounces of a %u byte message\n", total*10000,bounces,msgsize); printf("%u microseconds per message\n",(total*10000)/(bounces*2)); printf("%u bytes per second\n", (msgsize*2*bounces*100)/total); Free(buf); }
static void entry(void) { struct MsgPort *port1,*port2; struct Message *msg; Forbid(); port1=FindPort("message test port"); Permit(); port2=CreateMsgPort(); if(port2!=NULL) { msg=(struct Message *)CreateIORequest(port2,sizeof(struct Message)); if(msg!=NULL) { int i; for(i=0;i<10;i++) { msg->mn_Node.ln_Name=(char *)i; PutMsg(port1,msg); WaitPort(port2); GetMsg(port2); } DeleteIORequest((struct IORequest *)msg); } DeleteMsgPort(port2); } Signal(port1->mp_SigTask,1<<port1->mp_SigBit); Wait(0);/* Let the parent remove me */ }
VOID PutRequest(struct MsgPort *port, struct IORequest *request, struct DevBase *base) { request->io_Flags &= ~IOF_QUICK; PutMsg(port, (APTR)request); return; }
void AutotrainerSipCall::RedirectTo(const resip::Uri &destinationUri) { if (m_remoteParticipant.IsEmpty()) return; m_remoteParticipant->RedirectParticipant(resip::NameAddr(destinationUri)); PutMsg(this, &T::OnCommand); }
TestObject(DomainClass &domain, XHook &hook) : MsgObject(domain.getMsgThread()), m_domain(domain), m_hook(hook) { m_domain.getMsgThread().SetMaxMessageProcessingTimeMs(CMsgTimeout); PutMsg(this, &TestObject::Loop); }
// DCB context! void TdmHAL::OnBlockCollisionDCB(int count) { PutMsg(this, &TdmHAL::MsgOnBlockCollision); // m_mng.OnBlockCollision(); // std::cout << "TDM block collision " << count << std::endl; }
BOOL IPC_PutMsg( struct MsgPort *destino, IPCACT_T action, APTR udata ) { struct MsgPort *replyport = NULL; BOOL error = TRUE; ENTER(); DBG_POINTER(destino); if(destino && (replyport = CreateMsgPort())) { struct IPCMsg ipcmsg; APTR xMsg; ipcmsg.ipc_msg.mn_ReplyPort = replyport; ipcmsg.ipc_msg.mn_Length = sizeof(struct IPCMsg); ipcmsg.ipc_ID = IPC_MAGIC; ipcmsg.ipc_action = action; ipcmsg.ipc_result = IPCR_ABORTED; ipcmsg.ipc_data = udata; DBG("Sending action '%ld' from %lx to %lx\n", action, replyport, destino); Forbid(); PutMsg( destino, &ipcmsg.ipc_msg); WaitPort(replyport); while((xMsg = GetMsg( replyport ))) { DBG("Got reply...\n"); switch(((struct IPCMsg *)xMsg)->ipc_result) { // TODO case IPCR_ABORTED: DBG("IPCR_ABORTED\n"); break; case IPCR_FAIL: DBG("IPCR_FAIL\n"); break; case IPCR_OK: DBG("IPCR_OK\n"); break; default: break; } } Permit(); DeleteMsgPort(replyport); error = FALSE; } LEAVE(); return !error; }
void ASERDPort::send_to_proc(uint32 what, uint32 pb) { D(bug("sending %08lx to serial_proc\n", what)); SerMessage msg(what, reply_port); msg.pb = pb; PutMsg(proc_port, &msg); WaitPort(reply_port); GetMsg(reply_port); D(bug(" sent\n")); }