zmq::poll_t::handle_t zmq::poll_t::add_fd (fd_t fd_, i_poll_events *events_) { check_thread (); zmq_assert (fd_ != retired_fd); // If the file descriptor table is too small expand it. fd_table_t::size_type sz = fd_table.size (); if (sz <= (fd_table_t::size_type) fd_) { fd_table.resize (fd_ + 1); while (sz != (fd_table_t::size_type) (fd_ + 1)) { fd_table[sz].index = retired_fd; ++sz; } } pollfd pfd = {fd_, 0, 0}; pollset.push_back (pfd); zmq_assert (fd_table[fd_].index == retired_fd); fd_table[fd_].index = pollset.size () - 1; fd_table[fd_].events = events_; // Increase the load metric of the thread. adjust_load (1); return fd_; }
static void on_accept(PjUwpSocket *s) { pj_ioqueue_key_t *key = (pj_ioqueue_key_t*)s->GetUserData(); pj_ioqueue_t *ioq = key->ioqueue; check_thread(ioq); ioqueue_dispatch_read_event(key->ioqueue, key); }
static void on_connect(PjUwpSocket *s, pj_status_t status) { PJ_UNUSED_ARG(status); pj_ioqueue_key_t *key = (pj_ioqueue_key_t*)s->GetUserData(); pj_ioqueue_t *ioq = key->ioqueue; check_thread(ioq); ioqueue_dispatch_write_event(key->ioqueue, key); }
static void on_write(PjUwpSocket *s, int bytes_sent) { PJ_UNUSED_ARG(bytes_sent); pj_ioqueue_key_t *key = (pj_ioqueue_key_t*)s->GetUserData(); pj_ioqueue_t *ioq = key->ioqueue; check_thread(ioq); ioqueue_dispatch_write_event(key->ioqueue, key); //start_next_write(key); }
static void on_read(PjUwpSocket *s, int bytes_read) { pj_ioqueue_key_t *key = (pj_ioqueue_key_t*)s->GetUserData(); pj_ioqueue_t *ioq = key->ioqueue; check_thread(ioq); ioqueue_dispatch_read_event(key->ioqueue, key); if (bytes_read > 0) start_next_read(key); }
void zmq::poll_t::rm_fd (handle_t handle_) { check_thread (); fd_t index = fd_table[handle_].index; zmq_assert (index != retired_fd); // Mark the fd as unused. pollset[index].fd = retired_fd; fd_table[handle_].index = retired_fd; retired = true; // Decrease the load metric of the thread. adjust_load (-1); }
void zmq::poll_t::stop () { check_thread (); // no-op... thread is stopped when no more fds or timers are registered }
void zmq::poll_t::reset_pollout (handle_t handle_) { check_thread (); fd_t index = fd_table[handle_].index; pollset[index].events &= ~((short) POLLOUT); }
void zmq::poll_t::set_pollout (handle_t handle_) { check_thread (); fd_t index = fd_table[handle_].index; pollset[index].events |= POLLOUT; }
// メイン関数 int main( int argc, char *argv[] ) { FILE *fp = NULL; char *s; int i; int file_open = 0; // ファイルオープン確認フラグ // option解析 for(i = 1; i < argc; i++){ if(argv[i][0] == '-'){ if(argv[i][1] == 't') g_thread = strtol(argv[i] + 2, &s, 10); else if(argv[i][1] == 'r') g_auto_repair = 1; else if(argv[i][1] == 'l') g_rotation = strtol(argv[i] + 2, &s, 10) + 1; else if(argv[i][1] == 'd') g_debug_mode = 1; else if(argv[i][1] == 'h'){ switch(argv[i][2]) { case 'c': g_console = CONSOLE_COLORGAMEBOY; break; case 'g': g_console = CONSOLE_GAMEBOY; break; case 'n': g_console = CONSOLE_NEOGEOPOCKETCOLOR; break; case 'w': g_console = CONSOLE_SWANCRYSTAL; break; case 'p': g_console = CONSOLE_PIECE; break; case 's': g_console = CONSOLE_GAMEGEAR; break; default: printf("パラメータがおかしい = %c\n", argv[i][2]); show_opt(fp, argv[0]); break; } } else if(argv[i][1] == 'v') show_opt(fp, argv[0]); else { printf("パラメータがおかしい = %s\n", argv[i]); show_opt(fp, argv[0]); } } else if(file_open == 0){ fp = fopen( argv[i], "rb"); /* ファイルオープン(読み込みモード) */ if(fp == NULL){ /* オープン失敗 */ printf("ファイルがオープンできません\n"); exit(-1); } else file_open = 1; } } if (fp == NULL) show_opt(fp, argv[0]); // 変数への初期設定 if (g_console == 0) show_opt(fp, argv[0]); // ハード選択必須 g_thread = check_thread(g_thread); g_rotation = check_rotation(g_rotation); set_xy(g_rotation); // 情報出力 show_outputdata(g_thread, g_rotation); // メイン処理 rawtopng(fp); // ファイルクローズ fclose(fp); return 0; }