#include <stdio.h>
#include <uv.h>
Go to the source code of this file.
◆ main()
Definition at line 37 of file main.c.
46 int thread_nums[] = {1, 2, 1};
static uv_thread_t * threads
UV_EXTERN int uv_barrier_init(uv_barrier_t *barrier, unsigned int count)
UV_EXTERN int uv_rwlock_init(uv_rwlock_t *rwlock)
UV_EXTERN int uv_barrier_wait(uv_barrier_t *barrier)
UV_EXTERN void uv_barrier_destroy(uv_barrier_t *barrier)
UV_EXTERN int uv_thread_create(uv_thread_t *tid, uv_thread_cb entry, void *arg)
UV_EXTERN void uv_rwlock_destroy(uv_rwlock_t *rwlock)
References blocker, numlock, reader(), shared_num, threads, uv_barrier_destroy(), uv_barrier_init(), uv_barrier_wait(), uv_rwlock_destroy(), uv_rwlock_init(), uv_thread_create(), and writer().
◆ reader()
Definition at line 8 of file main.c.
12 for (
i = 0;
i < 20;
i++) {
14 printf(
"Reader %d: acquired lock\n",
num);
17 printf(
"Reader %d: released lock\n",
num);
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig const char static mode static oldfd struct tms static buf static getgid static geteuid const char static filename static arg static mask struct ustat static ubuf static getppid static setsid static egid sigset_t static set struct timeval struct timezone static tz fd_set fd_set fd_set struct timeval static timeout const char char static bufsiz const char static swapflags void static offset const char static length static mode static who const char struct statfs static buf unsigned unsigned num
UV_EXTERN void uv_rwlock_rdlock(uv_rwlock_t *rwlock)
UV_EXTERN void uv_rwlock_rdunlock(uv_rwlock_t *rwlock)
References blocker, i, n, num, numlock, printf(), shared_num, uv_barrier_wait(), uv_rwlock_rdlock(), and uv_rwlock_rdunlock().
Referenced by main().
◆ writer()
Definition at line 22 of file main.c.
26 for (
i = 0;
i < 20;
i++) {
28 printf(
"Writer %d: acquired lock\n",
num);
32 printf(
"Writer %d: released lock\n",
num);
UV_EXTERN void uv_rwlock_wrlock(uv_rwlock_t *rwlock)
UV_EXTERN void uv_rwlock_wrunlock(uv_rwlock_t *rwlock)
References blocker, i, n, num, numlock, printf(), shared_num, uv_barrier_wait(), uv_rwlock_wrlock(), and uv_rwlock_wrunlock().
Referenced by main(), and ts_subtree__write_to_string().
◆ blocker
◆ numlock
◆ shared_num