IoValue *IoSocket_waitForConnect(IoSocket *self, IoValue *locals, IoMessage *m) { IoState* state = (IoState*)self->tag->state; while(!self->isConnected) { IoState_yield(state); } return (IoValue*)self; }
IoValue *IoSocket_waitForReadLine(IoSocket *self, IoValue *locals, IoMessage *m) { IoState* state = (IoState*)self->tag->state; while(!self->lineRead) { IoState_yield(state); } IoValue* value = (IoValue*)USTRING(self->lineRead); free(self->lineRead); self->lineRead = 0; return (IoValue*)value; }
IoValue *IoSocket_connect(IoSocket *self, IoValue *locals, IoMessage *m) { if(self->activeConnect) { delete self->activeConnect; } self->activeConnect = CConnectingSocket::NewL(self->socket, self); self->activeConnect->StartConnectL(); IoState* state = (IoState*)self->tag->state; while(!self->isConnected) { IoState_yield(state); } return (IoValue*)self; }
IoValue *IoSocket_readLine(IoSocket *self, IoValue *locals, IoMessage *m) { IoNumber *size = (IoNumber*)IoMessage_locals_numberArgAt_(m, locals, 0); IoState* state = (IoState*)self->tag->state; if(self->activeReadLine) { delete self->activeReadLine; self->activeReadLine = 0; } int trueSize = IoNumber_asInt(size); char* buffer = (char*)malloc(trueSize + 1); memset(buffer, 0, trueSize + 1); self->activeReadLine = CReadLineSocket::NewL(self->socket, self, buffer, trueSize); self->activeReadLine->StartReadLineL(); while(!self->lineRead) { IoState_yield(state); } IoValue* value = (IoValue*)USTRING(self->lineRead); free(self->lineRead); self->lineRead = 0; return (IoValue*)value; }
static int IoSQLite3_busyHandler(void *context, int n) { IoSQLite3 *self = context; IoState_yield(IOSTATE); return 1; }
static int IoSQLite_busyHandler(void *context, const char *s, int n) { IoSQLite *self = context; IoState_yield(IOSTATE); return 1; }