Пример #1
0
/// \brief  The thread to print Board to screen
/// \param  arg Void
/// \return void* NULL
void* t_NetworkSend(void* arg){
    pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS , NULL);
    int oldtype;
    while(1){
        pthread_testcancel();
        pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype);
        pthread_mutex_lock(&MNet);
        pthread_cond_wait (&CNet, &MNet);
        pthread_testcancel();
        pthread_mutex_lock(&MBoard);
        c_writeBoardToDisk(0,false);
        FILE *fp;
        char name[20];
        int ver=c_version();
        sprintf(name,"2048.0.%X.save",ver);
        if((fp=fopen(name,"r"))) {
            int c;
            int count = 500;
            while (count--) {
                if ((c = fgetc(fp)) != EOF) {
                    dyad_write(SGaming, &c, 1);
                } else {
                    dyad_update();
                    break;
                }
            }
        }else{
            dyad_writef(SGaming, "ERR");
        }
        pthread_mutex_unlock(&MBoard);
        pthread_mutex_unlock(&MNet);
        pthread_setcanceltype(oldtype, NULL);
    }
    return NULL;
}
Пример #2
0
static void onData(dyad_Event *e) {
  dyad_write(e->stream, e->data, e->size);
}
Пример #3
0
		void write(const void *data, int size) {
			dyad_write(m_wrap, data, size);
		}