/* block the current thread on the specified port */ static sexp sexp_blocker (sexp ctx, sexp self, sexp_sint_t n, sexp port) { int fd; sexp_assert_type(ctx, sexp_portp, SEXP_IPORT, port); /* register the fd */ fd = sexp_port_fileno(port); if (fd >= 0) sexp_insert_pollfd(ctx, fd, sexp_iportp(port) ? POLLIN : POLLOUT); /* pause the current thread */ sexp_context_waitp(ctx) = 1; sexp_context_event(ctx) = port; sexp_insert_timed(ctx, ctx, SEXP_FALSE); return SEXP_VOID; }
/* block the current thread on the specified port */ static sexp sexp_blocker (sexp ctx, sexp self, sexp_sint_t n, sexp portorfd) { int fd; /* register the fd */ if (sexp_portp(portorfd)) fd = sexp_port_fileno(portorfd); else if (sexp_filenop(portorfd)) fd = sexp_fileno_fd(portorfd); else if (sexp_fixnump(portorfd)) fd = sexp_unbox_fixnum(portorfd); else return sexp_type_exception(ctx, self, SEXP_IPORT, portorfd); if (fd >= 0) sexp_insert_pollfd(ctx, fd, sexp_oportp(portorfd) ? POLLOUT : POLLIN); /* pause the current thread */ sexp_context_waitp(ctx) = 1; sexp_context_event(ctx) = portorfd; sexp_insert_timed(ctx, ctx, SEXP_FALSE); return SEXP_VOID; }