您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ uv_ref函数代码示例

51自学网 2021-06-03 09:28:06
  C++
这篇教程C++ uv_ref函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中uv_ref函数的典型用法代码示例。如果您正苦于以下问题:C++ uv_ref函数的具体用法?C++ uv_ref怎么用?C++ uv_ref使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了uv_ref函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: uv__tcp_connect6

int uv__tcp_connect6(uv_connect_t* req,                     uv_tcp_t* handle,                     struct sockaddr_in6 address,                     uv_connect_cb cb) {  uv_loop_t* loop = handle->loop;  int addrsize = sizeof(struct sockaddr_in6);  BOOL success;  DWORD bytes;  if (!uv_allow_ipv6) {    uv__set_sys_error(loop, WSAEAFNOSUPPORT);    return -1;  }  if (handle->flags & UV_HANDLE_BIND_ERROR) {    uv__set_sys_error(loop, handle->bind_error);    return -1;  }  if (!(handle->flags & UV_HANDLE_BOUND) &&      uv_tcp_bind6(handle, uv_addr_ip6_any_) < 0)    return -1;  if (!handle->func_connectex) {    if(!uv_get_connectex_function(handle->socket, &handle->func_connectex)) {      uv__set_sys_error(loop, WSAEAFNOSUPPORT);      return -1;    }  }  uv_req_init(loop, (uv_req_t*) req);  req->type = UV_CONNECT;  req->handle = (uv_stream_t*) handle;  req->cb = cb;  memset(&req->overlapped, 0, sizeof(req->overlapped));  success = handle->func_connectex(handle->socket,                                   (struct sockaddr*) &address,                                   addrsize,                                   NULL,                                   0,                                   &bytes,                                   &req->overlapped);  if (UV_SUCCEEDED_WITHOUT_IOCP(success)) {    handle->reqs_pending++;    uv_ref(loop);    uv_insert_pending_req(loop, (uv_req_t*)req);  } else if (UV_SUCCEEDED_WITH_IOCP(success)) {    handle->reqs_pending++;    uv_ref(loop);  } else {    uv__set_sys_error(loop, WSAGetLastError());    return -1;  }  return 0;}
开发者ID:InfamousNugz,项目名称:dnscrypt-proxy,代码行数:58,


示例2: NODE_VERSION_AT_LEAST

void CefLoop::Run() {  if( !CefLoop::initialized_ || CefLoop::running_ ) return;#if NODE_VERSION_AT_LEAST(0, 7, 9)  uv_ref((uv_handle_t *)&g_async);#else  uv_ref(uv_default_loop());#endif  uv_timer_start(&timer,RunLoop,1,1);    CefLoop::running_ = true;}
开发者ID:276361270,项目名称:appjs,代码行数:14,


示例3: term

static void term(void *const unused) {	fprintf(stderr, "/nStopping StrongLink server.../n");	uv_ref((uv_handle_t *)sigint);	uv_signal_stop(sigint);	async_close((uv_handle_t *)sigint);	SLNRepoPullsStop(repo);	HTTPServerClose(server_raw);	HTTPServerClose(server_tls);	uv_ref((uv_handle_t *)sigpipe);	uv_signal_stop(sigpipe);	uv_close((uv_handle_t *)sigpipe, NULL);}
开发者ID:nkatsaros,项目名称:stronglink,代码行数:15,


示例4: socket_connect

static void socket_connect(MVMThreadContext *tc, MVMOSHandle *h, MVMString *host, MVMint64 port) {    MVMIOSyncSocketData *data = (MVMIOSyncSocketData *)h->body.data;    if (!data->ss.handle) {        struct sockaddr *dest    = MVM_io_resolve_host_name(tc, host, port);        uv_tcp_t        *socket  = MVM_malloc(sizeof(uv_tcp_t));        uv_connect_t    *connect = MVM_malloc(sizeof(uv_connect_t));        int r;        data->ss.cur_tc = tc;        connect->data   = data;        if ((r = uv_tcp_init(tc->loop, socket)) < 0 ||                (r = uv_tcp_connect(connect, socket, dest, on_connect)) < 0) {            MVM_free(socket);            MVM_free(connect);            MVM_free(dest);            MVM_exception_throw_adhoc(tc, "Failed to connect: %s", uv_strerror(r));        }        uv_ref((uv_handle_t *)socket);        uv_run(tc->loop, UV_RUN_DEFAULT);        data->ss.handle = (uv_stream_t *)socket;        MVM_free(connect);        MVM_free(dest);    }    else {        MVM_exception_throw_adhoc(tc, "Socket is already bound or connected");    }}
开发者ID:stmuk,项目名称:MoarVM,代码行数:29,


示例5: uv_fs_write

int uv_fs_write(uv_loop_t* loop, uv_fs_t* req, uv_file file, void* buf,    size_t length, off_t offset, uv_fs_cb cb) {  uv_fs_req_init(loop, req, UV_FS_WRITE, NULL, cb);  if (cb) {    /* async */    uv_ref(loop);    req->eio = eio_write(file, buf, length, offset, EIO_PRI_DEFAULT,        uv__fs_after, req);    if (!req->eio) {      uv_err_new(loop, ENOMEM);      return -1;    }  } else {    /* sync */    req->result = offset < 0 ?        write(file, buf, length) :        pwrite(file, buf, length, offset);    if (req->result < 0) {      uv_err_new(loop, errno);      return -1;    }  }  return 0;}
开发者ID:adrienschuler,项目名称:node,代码行数:28,


示例6: uv_fs_open

int uv_fs_open(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags,    int mode, uv_fs_cb cb) {  uv_fs_req_init(loop, req, UV_FS_OPEN, path, cb);  if (cb) {    /* async */    uv_ref(loop);    req->eio = eio_open(path, flags, mode, EIO_PRI_DEFAULT, uv__fs_after, req);    if (!req->eio) {      uv_err_new(loop, ENOMEM);      return -1;    }  } else {    /* sync */    req->result = open(path, flags, mode);    if (req->result < 0) {      uv_err_new(loop, errno);      return -1;    }    uv__cloexec(req->result, 1);  }  return 0;}
开发者ID:adrienschuler,项目名称:node,代码行数:26,


示例7: socket_accept

static MVMObject * socket_accept(MVMThreadContext *tc, MVMOSHandle *h) {    MVMIOSyncSocketData *data = (MVMIOSyncSocketData *)h->body.data;    while (!data->accept_server) {        uv_ref((uv_handle_t *)data->ss.handle);        uv_run(tc->loop, UV_RUN_DEFAULT);    }    /* Check the accept worked out. */    if (data->accept_status < 0) {        MVM_exception_throw_adhoc(tc, "Failed to listen: unknown error");    }    else {        uv_tcp_t *client    = malloc(sizeof(uv_tcp_t));        uv_stream_t *server = data->accept_server;        int r;        uv_tcp_init(tc->loop, client);        data->accept_server = NULL;        if ((r = uv_accept(server, (uv_stream_t *)client)) == 0) {            MVMOSHandle         * const result = (MVMOSHandle *)MVM_repr_alloc_init(tc, tc->instance->boot_types.BOOTIO);            MVMIOSyncSocketData * const data   = calloc(1, sizeof(MVMIOSyncSocketData));            data->ss.handle   = (uv_stream_t *)client;            data->ss.encoding = MVM_encoding_type_utf8;            data->ss.sep      = '/n';            result->body.ops  = &op_table;            result->body.data = data;            return (MVMObject *)result;        }        else {            uv_close((uv_handle_t*)client, NULL);            free(client);            MVM_exception_throw_adhoc(tc, "Failed to accept: %s", uv_strerror(r));        }    }}
开发者ID:grondilu,项目名称:MoarVM,代码行数:35,


示例8: MVM_io_syncstream_write_str

MVMint64 MVM_io_syncstream_write_str(MVMThreadContext *tc, MVMOSHandle *h, MVMString *str, MVMint64 newline) {    MVMIOSyncStreamData *data = (MVMIOSyncStreamData *)h->body.data;    MVMuint8 *output;    MVMint64 output_size;    uv_write_t *req;    uv_buf_t write_buf;    int r;    output = MVM_string_encode(tc, str, 0, -1, &output_size, data->encoding);    if (newline) {        output = (MVMuint8 *)realloc(output, ++output_size);        output[output_size - 1] = '/n';    }    req = malloc(sizeof(uv_write_t));    write_buf = uv_buf_init(output, output_size);    uv_ref((uv_handle_t *)data->handle);    if ((r = uv_write(req, data->handle, &write_buf, 1, write_cb)) < 0) {        uv_unref((uv_handle_t *)data->handle);        free(req);        free(output);        MVM_exception_throw_adhoc(tc, "Failed to write string to stream: %s", uv_strerror(r));    }    else {        uv_run(tc->loop, UV_RUN_DEFAULT);        free(output);    }    data->total_bytes_written += output_size;    return output_size;}
开发者ID:BlastarIndia,项目名称:MoarVM,代码行数:30,


示例9: uv_async_send

void NodeMap::startRender(NodeMap::RenderOptions options) {    view.resize(options.width, options.height);    map->update(mbgl::Update::Dimensions);    map->setClasses(options.classes);    map->setLatLngZoom(mbgl::LatLng(options.latitude, options.longitude), options.zoom);    map->setBearing(options.bearing);    map->setPitch(options.pitch);    map->setDebug(options.debugOptions);    map->renderStill([this](const std::exception_ptr eptr, mbgl::PremultipliedImage&& result) {        if (eptr) {            error = std::move(eptr);            uv_async_send(async);        } else {            assert(!image.data);            image = std::move(result);            uv_async_send(async);        }    });    // Retain this object, otherwise it might get destructed before we are finished rendering the    // still image.    Ref();    // Similarly, we're now waiting for the async to be called, so we need to make sure that it    // keeps the loop alive.    uv_ref(reinterpret_cast<uv_handle_t *>(async));}
开发者ID:AJcravea,项目名称:mapbox-gl-native,代码行数:28,


示例10: computeHomography

void computeHomography(    const vector<Vector3d>& f_ref,    const vector<Vector3d>& f_cur,    double focal_length,    double reprojection_threshold,    vector<int>& inliers,    vector<Vector3d>& xyz_in_cur,    SE3& T_cur_from_ref){  vector<Vector2d, aligned_allocator<Vector2d> > uv_ref(f_ref.size());  vector<Vector2d, aligned_allocator<Vector2d> > uv_cur(f_cur.size());  for(size_t i=0, i_max=f_ref.size(); i<i_max; ++i)  {    uv_ref[i] = vk::project2d(f_ref[i]);    uv_cur[i] = vk::project2d(f_cur[i]);  }  vk::Homography Homography(uv_ref, uv_cur, focal_length, reprojection_threshold);  Homography.computeSE3fromMatches();  vector<int> outliers;  vk::computeInliers(f_cur, f_ref,                     Homography.T_c2_from_c1.rotation_matrix(), Homography.T_c2_from_c1.translation(),                     reprojection_threshold, focal_length,                     xyz_in_cur, inliers, outliers);  T_cur_from_ref = Homography.T_c2_from_c1;}
开发者ID:JoonasMelin,项目名称:rpg_svo,代码行数:25,


示例11: uv_process_init

static void uv_process_init(uv_loop_t* loop, uv_process_t* handle) {  handle->type = UV_PROCESS;  handle->loop = loop;  handle->flags = 0;  handle->exit_cb = NULL;  handle->pid = 0;  handle->exit_signal = 0;  handle->wait_handle = INVALID_HANDLE_VALUE;  handle->process_handle = INVALID_HANDLE_VALUE;  handle->close_handle = INVALID_HANDLE_VALUE;  handle->child_stdio[0] = INVALID_HANDLE_VALUE;  handle->child_stdio[1] = INVALID_HANDLE_VALUE;  handle->child_stdio[2] = INVALID_HANDLE_VALUE;  uv_req_init(loop, (uv_req_t*)&handle->exit_req);  handle->exit_req.type = UV_PROCESS_EXIT;  handle->exit_req.data = handle;  uv_req_init(loop, (uv_req_t*)&handle->close_req);  handle->close_req.type = UV_PROCESS_CLOSE;  handle->close_req.data = handle;  loop->counters.handle_init++;  loop->counters.process_init++;  uv_ref(loop);}
开发者ID:HenryRawas,项目名称:libuv,代码行数:26,


示例12: uv_ref

EventLoop::~EventLoop() {	uv_ref((uv_handle_t*) &deleteObjectsHandle);	uv_prepare_stop(&deleteObjectsHandle);	uv_close((uv_handle_t*) &deleteObjectsHandle, nullptr);	// Wait remaining handle to close	uv_run(&loop, UV_RUN_DEFAULT);	if(uv_loop_alive(&loop)) {		log(LL_Warning, "Loop still used but delete requested, handles:/n");		uv_walk(&loop,		        [](uv_handle_t* handle, void* arg) {			        EventLoop* self = (EventLoop*) arg;			        const char* type;			        switch(handle->type) {#define X(uc, lc) /	case UV_##uc: /		type = #lc; /		break;				        UV_HANDLE_TYPE_MAP(X)#undef X				        default:					        type = "<unknown>";			        }			        self->log(LL_Warning, "  [%08X] %s %p/n", handle->flags, type, handle);		        },		        this);
开发者ID:glandu2,项目名称:librzu,代码行数:28,


示例13: couv_ref

static int couv_ref(lua_State *L) {  uv_handle_t *handle;  handle = couvL_checkudataclass(L, 1, COUV_HANDLE_MTBL_NAME);  uv_ref(handle);  return 0;}
开发者ID:AsamQi,项目名称:couv,代码行数:7,


示例14: HTTPConnectionReadRequest

ssize_t HTTPConnectionReadRequest(HTTPConnectionRef const conn, HTTPMethod *const method, str_t *const out, size_t const max) {	if(!conn) return UV_EINVAL;	if(!max) return UV_EINVAL;	uv_buf_t buf[1];	int rc;	HTTPEvent type;	size_t len = 0;	for(;;) {		// Use unref because we shouldn't block the server		// on a request that may never arrive.		uv_unref((uv_handle_t *)conn->stream);		rc = HTTPConnectionPeek(conn, &type, buf);		uv_ref((uv_handle_t *)conn->stream);		if(rc < 0) return rc;		if(HTTPHeaderField == type || HTTPHeadersComplete == type) break;		HTTPConnectionPop(conn, buf->len);		if(HTTPMessageBegin == type) continue;		if(HTTPURL != type) {			assertf(0, "Unexpected HTTP event %d", type);			return UV_UNKNOWN;		}		if(len+buf->len+1 > max) return UV_EMSGSIZE;		memcpy(out+len, buf->base, buf->len);		len += buf->len;		out[len] = '/0';	}	*method = conn->parser->method;	return (ssize_t)len;}
开发者ID:rmoorman,项目名称:stronglink,代码行数:29,


示例15: uv_process_init

static void uv_process_init(uv_process_t* handle) {  handle->type = UV_PROCESS;  handle->flags = 0;  handle->error = uv_ok_;  handle->exit_cb = NULL;  handle->pid = 0;  handle->exit_signal = 0;  handle->wait_handle = INVALID_HANDLE_VALUE;  handle->process_handle = INVALID_HANDLE_VALUE;  handle->close_handle = INVALID_HANDLE_VALUE;  handle->stdio_pipes[0].server_pipe = NULL;  handle->stdio_pipes[0].child_pipe = INVALID_HANDLE_VALUE;  handle->stdio_pipes[1].server_pipe = NULL;  handle->stdio_pipes[1].child_pipe = INVALID_HANDLE_VALUE;  handle->stdio_pipes[2].server_pipe = NULL;  handle->stdio_pipes[2].child_pipe = INVALID_HANDLE_VALUE;  uv_req_init((uv_req_t*)&handle->exit_req);  handle->exit_req.type = UV_PROCESS_EXIT;  handle->exit_req.data = handle;  uv_req_init((uv_req_t*)&handle->close_req);  handle->close_req.type = UV_PROCESS_CLOSE;  handle->close_req.data = handle;  uv_counters()->handle_init++;  uv_counters()->process_init++;  uv_ref();}
开发者ID:changloong,项目名称:gool,代码行数:29,


示例16: uv_fs_event_init_handle

static void uv_fs_event_init_handle(uv_loop_t* loop, uv_fs_event_t* handle,    const char* filename, uv_fs_event_cb cb) {  handle->type = UV_FS_EVENT;  handle->loop = loop;  handle->flags = 0;  handle->cb = cb;  handle->is_path_dir = 0;  handle->dir_handle = INVALID_HANDLE_VALUE;  handle->buffer = NULL;  handle->req_pending = 0;  handle->filew = NULL;  handle->short_filew = NULL;  uv_req_init(loop, (uv_req_t*)&handle->req);  handle->req.type = UV_FS_EVENT_REQ;  handle->req.data = (void*)handle;  handle->filename = strdup(filename);  if (!handle->filename) {    uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");  }  loop->counters.handle_init++;  loop->counters.fs_event_init++;  uv_ref(loop);}
开发者ID:Laner,项目名称:gitbin,代码行数:27,


示例17: assert

/* * Class:     com_oracle_libuv_handles_Handle * Method:    _ref * Signature: (J)V */JNIEXPORT void JNICALL Java_com_oracle_libuv_handles_Handle__1ref  (JNIEnv *env, jobject that, jlong ptr) {  assert(ptr);  uv_handle_t* handle = reinterpret_cast<uv_handle_t*>(ptr);  uv_ref(handle);}
开发者ID:dannyzhu,项目名称:jlibuv,代码行数:12,


示例18: uv_fs_fstat

int uv_fs_fstat(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) {  uv_fs_req_init(loop, req, UV_FS_FSTAT, NULL, cb);  if (cb) {    /* async */    uv_ref(loop);    req->eio = eio_fstat(file, EIO_PRI_DEFAULT, uv__fs_after, req);    if (!req->eio) {      uv_err_new(loop, ENOMEM);      return -1;    }  } else {    /* sync */    req->result = fstat(file, &req->statbuf);    if (req->result < 0) {      uv_err_new(loop, errno);      return -1;    }    req->ptr = &req->statbuf;  }  return 0;}
开发者ID:adrienschuler,项目名称:node,代码行数:27,


示例19: uv_fs_readdir

int uv_fs_readdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags,    uv_fs_cb cb) {  int r;  struct dirent* entry;  size_t size = 0;  size_t d_namlen = 0;  uv_fs_req_init(loop, req, UV_FS_READDIR, path, cb);  if (cb) {    /* async */    uv_ref(loop);    req->eio = eio_readdir(path, flags, EIO_PRI_DEFAULT, uv__fs_after, req);    if (!req->eio) {      uv_err_new(loop, ENOMEM);      return -1;    }  } else {    /* sync */    DIR* dir = opendir(path);    if (!dir) {      uv_err_new(loop, errno);      req->result = -1;      return -1;    }    /* req->result stores number of entries */    req->result = 0;    while ((entry = readdir(dir))) {      d_namlen = strlen(entry->d_name);      /* Skip . and .. */      if ((d_namlen == 1 && entry->d_name[0] == '.') ||          (d_namlen == 2 && entry->d_name[0] == '.' &&           entry->d_name[1] == '.')) {        continue;      }      req->ptr = realloc(req->ptr, size + d_namlen + 1);      /* TODO check ENOMEM */      memcpy((char*)req->ptr + size, entry->d_name, d_namlen);      size += d_namlen;      ((char*)req->ptr)[size] = '/0';      size++;      req->result++;    }    r = closedir(dir);    if (r) {      uv_err_new(loop, errno);      req->result = -1;      return -1;    }  }  return 0;}
开发者ID:adrienschuler,项目名称:node,代码行数:59,


示例20: Handle_func_ref

static PyObject *Handle_func_ref(Handle *self){    RAISE_IF_HANDLE_NOT_INITIALIZED(self, NULL);    RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL);    uv_ref(self->uv_handle);    Py_RETURN_NONE;}
开发者ID:ayanamist,项目名称:pyuv,代码行数:8,


示例21: uv_mutex_lock

void EventStream::add(Event * event) {  uv_mutex_lock(&mutex);  eventVector.push_back(event);  uv_ref(reinterpret_cast<uv_handle_t *>(&async));  uv_mutex_unlock(&mutex);  uv_async_send(&async);}
开发者ID:mross-pivotal,项目名称:node-gemfire,代码行数:9,


示例22: uv_stream_init

void uv_stream_init(uv_stream_t* handle) {  handle->write_queue_size = 0;  handle->flags = 0;  handle->error = uv_ok_;  uv_counters()->handle_init++;  uv_counters()->stream_init++;  uv_ref();}
开发者ID:changloong,项目名称:gool,代码行数:10,


示例23: term

static void term(void *const unused) {	fprintf(stderr, "/n");	alogf("Stopping StrongLink server.../n");	uv_ref((uv_handle_t *)sigint);	uv_signal_stop(sigint);	async_close((uv_handle_t *)sigint);	SLNRepoPullsStop(repo);	HTTPServerClose(server_raw);	HTTPServerClose(server_tls);	async_pool_enter(NULL);	fflush(NULL); // Everything.	async_pool_leave(NULL);	uv_ref((uv_handle_t *)sigpipe);	uv_signal_stop(sigpipe);	uv_close((uv_handle_t *)sigpipe, NULL);}
开发者ID:andreydelpozo2,项目名称:stronglink,代码行数:20,


示例24: IAssert

void TSockSys::RefLoop() { 	IAssert(LoopRef == NULL);	// create new timer	LoopRef = (uv_timer_t*)malloc(sizeof(uv_timer_t));	// initialize	uv_timer_init(Loop, LoopRef);	// start the timer	uv_timer_start(LoopRef, LoopRefCallback, 0, 60000);	// reference the timer	uv_ref((uv_handle_t*)LoopRef); }
开发者ID:davidd2k,项目名称:qminer,代码行数:11,


示例25: uv_queue_work

int uv_queue_work(uv_loop_t* loop, uv_work_t* req, uv_work_cb work_cb,    uv_after_work_cb after_work_cb) {  uv_work_req_init(loop, req, work_cb, after_work_cb);  if (!QueueUserWorkItem(&uv_work_thread_proc, req, WT_EXECUTELONGFUNCTION)) {    uv_set_sys_error(loop, GetLastError());    return -1;  }  uv_ref(loop);  return 0;}
开发者ID:BillBarnhill,项目名称:node-custom,代码行数:12,


示例26: uv__udp_send

static int uv__udp_send(uv_udp_send_t* req, uv_udp_t* handle, uv_buf_t bufs[],    int bufcnt, struct sockaddr* addr, int addr_len, uv_udp_send_cb cb) {  uv_loop_t* loop = handle->loop;  DWORD result, bytes;  uv_req_init(loop, (uv_req_t*) req);  req->type = UV_UDP_SEND;  req->handle = handle;  req->cb = cb;  memset(&req->overlapped, 0, sizeof(req->overlapped));  result = WSASendTo(handle->socket,                     (WSABUF*)bufs,                     bufcnt,                     &bytes,                     0,                     addr,                     addr_len,                     &req->overlapped,                     NULL);  if (UV_SUCCEEDED_WITHOUT_IOCP(result == 0)) {    /* Request completed immediately. */    req->queued_bytes = 0;    handle->reqs_pending++;    uv_ref(loop);    uv_insert_pending_req(loop, (uv_req_t*)req);  } else if (UV_SUCCEEDED_WITH_IOCP(result == 0)) {    /* Request queued by the kernel. */    req->queued_bytes = uv_count_bufs(bufs, bufcnt);    handle->reqs_pending++;    uv_ref(loop);  } else {    /* Send failed due to an error. */    uv__set_sys_error(loop, WSAGetLastError());    return -1;  }  return 0;}
开发者ID:geraldfong,项目名称:svprep,代码行数:40,


示例27: uv_fs_readlink

int uv_fs_readlink(uv_loop_t* loop, uv_fs_t* req, const char* path,    uv_fs_cb cb) {  ssize_t size;  int status;  char* buf;  status = -1;  uv_fs_req_init(loop, req, UV_FS_READLINK, path, cb);  if (cb) {    if ((req->eio = eio_readlink(path, EIO_PRI_DEFAULT, uv__fs_after, req))) {      uv_ref(loop);      return 0;    } else {      uv_err_new(loop, ENOMEM);      return -1;    }  } else {    /* pathconf(_PC_PATH_MAX) may return -1 to signify that path     * lengths have no upper limit or aren't suitable for malloc'ing.     */    if ((size = pathconf(path, _PC_PATH_MAX)) == -1) {#if defined(PATH_MAX)      size = PATH_MAX;#else      size = 4096;#endif    }    if ((buf = malloc(size + 1)) == NULL) {      uv_err_new(loop, ENOMEM);      return -1;    }    if ((size = readlink(path, buf, size)) == -1) {      req->errorno = errno;      req->result = -1;      free(buf);    } else {      /* Cannot conceivably fail since it shrinks the buffer. */      buf = realloc(buf, size + 1);      buf[size] = '/0';      req->result = 0;      req->ptr = buf;    }    return 0;  }  assert(0 && "unreachable");}
开发者ID:adrienschuler,项目名称:node,代码行数:52,


示例28: DecodeBaton

    DecodeBaton() :        width(0),        height(0),        result(NULL),        resultLength(0)    {#if NODE_MAJOR_VERSION == 0 && NODE_MINOR_VERSION <= 4        ev_ref(EV_DEFAULT_UC);#else        this->request.data = this;        uv_ref(uv_default_loop());#endif    }
开发者ID:netconstructor,项目名称:tilelive-s3,代码行数:13,


示例29: uv_getaddrinfo

/* stub implementation of uv_getaddrinfo */int uv_getaddrinfo(uv_loop_t* loop,                   uv_getaddrinfo_t* handle,                   uv_getaddrinfo_cb cb,                   const char* hostname,                   const char* service,                   const struct addrinfo* hints) {  eio_req* req;  uv_eio_init(loop);  if (handle == NULL || cb == NULL ||      (hostname == NULL && service == NULL)) {    uv__set_artificial_error(loop, UV_EINVAL);    return -1;  }  uv__req_init(loop, (uv_req_t*)handle);  handle->type = UV_GETADDRINFO;  handle->loop = loop;  handle->cb = cb;  /* TODO don't alloc so much. */  if (hints) {    handle->hints = malloc(sizeof(struct addrinfo));    memcpy(handle->hints, hints, sizeof(struct addrinfo));  }  else {    handle->hints = NULL;  }  /* TODO security! check lengths, check return values. */  handle->hostname = hostname ? strdup(hostname) : NULL;  handle->service = service ? strdup(service) : NULL;  handle->res = NULL;  handle->retcode = 0;  /* TODO check handle->hostname == NULL */  /* TODO check handle->service == NULL */  uv_ref(loop);  req = eio_custom(getaddrinfo_thread_proc, EIO_PRI_DEFAULT,      uv_getaddrinfo_done, handle, &loop->uv_eio_channel);  assert(req);  assert(req->data == handle);  return 0;}
开发者ID:Maxence,项目名称:node,代码行数:50,



注:本文中的uv_ref函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ uv_req_init函数代码示例
C++ uv_read_stop函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。