Skip to content
This repository has been archived by the owner on Dec 1, 2020. It is now read-only.

libtuv APIs

SaeHie Park edited this page Dec 4, 2015 · 5 revisions

loop

  • int uv_loop_init(uv_loop_t* loop);
  • int uv_loop_close(uv_loop_t* loop);
  • uv_loop_t* uv_default_loop(void);
  • int uv_run(uv_loop_t* loop, uv_run_mode mode);
  • void uv_update_time(uv_loop_t*);
  • uint64_t uv_now(const uv_loop_t*);

handle

  • void uv_ref(uv_handle_t*);
  • void uv_unref(uv_handle_t*);
  • int uv_is_active(const uv_handle_t* handle);
  • void uv_close(uv_handle_t* handle, uv_close_cb close_cb);
  • void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg); * void uv_deinit(uv_loop_t* loop, uv_handle_t* handle);
    • new; explicitly de-init handle so that loop can be closed correctly.
    • call before uv_loop_close()

idle

  • int uv_idle_init(uv_loop_t* loop, uv_idle_t* handle);
  • int uv_idle_start(uv_idle_t* handle, uv_idle_cb cb);
  • int uv_idle_stop(uv_idle_t* handle);

timer

  • int uv_timer_init(uv_loop_t*, uv_timer_t* handle);
  • int uv_timer_start(uv_timer_t* handle, uv_timer_cb cb, uint64_t timeout, uint64_t repeat);
  • int uv_timer_stop(uv_timer_t* handle);
  • int uv_timer_again(uv_timer_t* handle);
  • void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat);
  • uint64_t uv_timer_get_repeat(const uv_timer_t* handle);

async

  • int uv_async_init(uv_loop_t*, uv_async_t* async, uv_async_cb async_cb);
  • int uv_async_send(uv_async_t* async);

fs

  • int uv_fs_open(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags,int mode, uv_fs_cb cb);
  • int uv_fs_close(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb);
  • int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, uv_file file, const uv_buf_t bufs[], unsigned int nbufs, int64_t offset, uv_fs_cb cb);
  • int uv_fs_write(uv_loop_t* loop, uv_fs_t* req, uv_file file, const uv_buf_t bufs[], unsigned int nbufs, int64_t offset, uv_fs_cb cb);
  • int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb);
  • int uv_fs_fstat(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb);
  • int uv_fs_fsync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb);
  • int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb);
  • int uv_fs_unlink(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb);
  • int uv_fs_ftruncate(uv_loop_t* loop, uv_fs_t* req, uv_file file, int64_t offset, uv_fs_cb cb);
  • int uv_fs_rename(uv_loop_t* loop, uv_fs_t* req, const char* path, const char* new_path, uv_fs_cb cb);
  • int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file file, double atime, double mtime, uv_fs_cb cb);
  • int uv_fs_utime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime, double mtime, uv_fs_cb cb);
  • void uv_fs_req_cleanup(uv_fs_t* req);

stream

  • int uv_read_start(uv_stream_t*, uv_alloc_cb alloc_cb, uv_read_cb read_cb);
  • int uv_read_stop(uv_stream_t*);
  • int uv_write(uv_write_t* req, uv_stream_t* handle, const uv_buf_t bufs[], unsigned int nbufs, uv_write_cb cb);
  • int uv_write2(uv_write_t* req, uv_stream_t* handle, const uv_buf_t bufs[], unsigned int nbufs, uv_stream_t* send_handle, uv_write_cb cb);
  • int uv_try_write(uv_stream_t* handle, const uv_buf_t bufs[], unsigned int nbufs);

directory

  • int uv_cwd(char* buffer, size_t* size);

network

  • int uv_inet_ntop(int af, const void* src, char* dst, size_t size);
  • int uv_inet_pton(int af, const char* src, void* dst);
  • int uv_ip4_addr(const char* ip, int port, struct sockaddr_in* addr);
  • int uv_ip4_name(const struct sockaddr_in* src, char* dst, size_t size);
  • int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb);
  • int uv_accept(uv_stream_t* server, uv_stream_t* client);
  • int uv_tcp_init(uv_loop_t*, uv_tcp_t* handle);
  • int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock);
  • int uv_tcp_keepalive(uv_tcp_t* handle, int enable, unsigned int delay);
  • int uv_tcp_bind(uv_tcp_t* handle, const struct sockaddr* addr, unsigned int flags);
  • int uv_tcp_connect(uv_connect_t* req, uv_tcp_t* handle, const struct sockaddr* addr, uv_connect_cb cb);
  • int uv_tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb);
  • int uv_shutdown(uv_shutdown_t* req, uv_stream_t* handle, uv_shutdown_cb cb);

threading and synchronisation

  • int uv_thread_create(uv_thread_t* tid, uv_thread_cb entry, void* arg);
  • uv_thread_t uv_thread_self(void);
  • int uv_thread_join(uv_thread_t *tid);
  • int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2);
  • void uv_once(uv_once_t* guard, void (*callback)(void));
  • int uv_mutex_init(uv_mutex_t* handle);
  • void uv_mutex_destroy(uv_mutex_t* handle);
  • void uv_mutex_lock(uv_mutex_t* handle);
  • int uv_mutex_trylock(uv_mutex_t* handle);
  • void uv_mutex_unlock(uv_mutex_t* handle);
  • int uv_sem_init(uv_sem_t* sem, unsigned int value);
  • void uv_sem_destroy(uv_sem_t* sem);
  • void uv_sem_post(uv_sem_t* sem);
  • void uv_sem_wait(uv_sem_t* sem);
  • int uv_sem_trywait(uv_sem_t* sem);
  • int uv_cond_init(uv_cond_t* cond);
  • void uv_cond_destroy(uv_cond_t* cond);
  • void uv_cond_signal(uv_cond_t* cond);
  • void uv_cond_broadcast(uv_cond_t* cond);
  • void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex);
  • int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, uint64_t timeout);
  • int uv_rwlock_init(uv_rwlock_t* rwlock);
  • void uv_rwlock_destroy(uv_rwlock_t* rwlock);
  • void uv_rwlock_rdlock(uv_rwlock_t* rwlock);
  • int uv_rwlock_tryrdlock(uv_rwlock_t* rwlock);
  • void uv_rwlock_rdunlock(uv_rwlock_t* rwlock);
  • void uv_rwlock_wrlock(uv_rwlock_t* rwlock);
  • int uv_rwlock_trywrlock(uv_rwlock_t* rwlock);
  • void uv_rwlock_wrunlock(uv_rwlock_t* rwlock);

thread pool and work schedule

  • int uv_queue_work(uv_loop_t* loop, uv_work_t* req, uv_work_cb work_cb, uv_after_work_cb after_work_cb);

request

  • int uv_cancel(uv_req_t* req);

miscellaneous utilities

  • uv_buf_t uv_buf_init(char* base, unsigned int len);