diff options
author | Luke Chen <luke.chen@mongodb.com> | 2019-08-21 05:23:37 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-08-21 05:23:37 +0000 |
commit | ac41c65f6355f83aac70136324c98561ac79daa1 (patch) | |
tree | a7c3f7ef090b59c6a06838a02c96bd1d49e1c729 /src/third_party/wiredtiger/src/os_posix/os_thread.c | |
parent | f54709196711c63a429b71f47c584661286d675f (diff) | |
download | mongo-ac41c65f6355f83aac70136324c98561ac79daa1.tar.gz |
Import wiredtiger: 7dfd9391862bc9a6d84868c4dc51689c45a3aacf from branch mongodb-4.4
ref: c809757d8b..7dfd939186
for: 4.3.1
WT-4658 Apply Clang Format
WT-4810 Adding WT_ERR_ASSERT and WT_RET_ASSERT macros
WT-5046 Prepared transactions aren't properly cleared from global table with WT_CONN_LOG_DEBUG_MODE enabled
Diffstat (limited to 'src/third_party/wiredtiger/src/os_posix/os_thread.c')
-rw-r--r-- | src/third_party/wiredtiger/src/os_posix/os_thread.c | 115 |
1 files changed, 54 insertions, 61 deletions
diff --git a/src/third_party/wiredtiger/src/os_posix/os_thread.c b/src/third_party/wiredtiger/src/os_posix/os_thread.c index 613df15d6d0..bc0e739c193 100644 --- a/src/third_party/wiredtiger/src/os_posix/os_thread.c +++ b/src/third_party/wiredtiger/src/os_posix/os_thread.c @@ -10,112 +10,105 @@ /* * __wt_thread_create -- - * Create a new thread of control. + * Create a new thread of control. */ int -__wt_thread_create(WT_SESSION_IMPL *session, - wt_thread_t *tidret, WT_THREAD_CALLBACK(*func)(void *), void *arg) - WT_GCC_FUNC_ATTRIBUTE((visibility("default"))) +__wt_thread_create(WT_SESSION_IMPL *session, wt_thread_t *tidret, + WT_THREAD_CALLBACK (*func)(void *), void *arg) WT_GCC_FUNC_ATTRIBUTE((visibility("default"))) { - WT_DECL_RET; + WT_DECL_RET; - /* - * Creating a thread isn't a memory barrier, but WiredTiger commonly - * sets flags and or state and then expects worker threads to start. - * Include a barrier to ensure safety in those cases. - */ - WT_FULL_BARRIER(); + /* + * Creating a thread isn't a memory barrier, but WiredTiger commonly sets flags and or state and + * then expects worker threads to start. Include a barrier to ensure safety in those cases. + */ + WT_FULL_BARRIER(); - /* Spawn a new thread of control. */ - WT_SYSCALL_RETRY(pthread_create(&tidret->id, NULL, func, arg), ret); - if (ret == 0) { - tidret->created = true; - return (0); - } - WT_RET_MSG(session, ret, "pthread_create"); + /* Spawn a new thread of control. */ + WT_SYSCALL_RETRY(pthread_create(&tidret->id, NULL, func, arg), ret); + if (ret == 0) { + tidret->created = true; + return (0); + } + WT_RET_MSG(session, ret, "pthread_create"); } /* * __wt_thread_join -- - * Wait for a thread of control to exit. + * Wait for a thread of control to exit. */ int __wt_thread_join(WT_SESSION_IMPL *session, wt_thread_t *tid) - WT_GCC_FUNC_ATTRIBUTE((visibility("default"))) + WT_GCC_FUNC_ATTRIBUTE((visibility("default"))) { - WT_DECL_RET; + WT_DECL_RET; - /* Only attempt to join if thread was created successfully */ - if (!tid->created) - return (0); - tid->created = false; + /* Only attempt to join if thread was created successfully */ + if (!tid->created) + return (0); + tid->created = false; - /* - * Joining a thread isn't a memory barrier, but WiredTiger commonly - * sets flags and or state and then expects worker threads to halt. - * Include a barrier to ensure safety in those cases. - */ - WT_FULL_BARRIER(); + /* + * Joining a thread isn't a memory barrier, but WiredTiger commonly sets flags and or state and + * then expects worker threads to halt. Include a barrier to ensure safety in those cases. + */ + WT_FULL_BARRIER(); - WT_SYSCALL(pthread_join(tid->id, NULL), ret); - if (ret == 0) - return (0); + WT_SYSCALL(pthread_join(tid->id, NULL), ret); + if (ret == 0) + return (0); - WT_RET_MSG(session, ret, "pthread_join"); + WT_RET_MSG(session, ret, "pthread_join"); } /* * __wt_thread_id -- - * Return an arithmetic representation of a thread ID on POSIX. + * Return an arithmetic representation of a thread ID on POSIX. */ void -__wt_thread_id(uintmax_t *id) - WT_GCC_FUNC_ATTRIBUTE((visibility("default"))) +__wt_thread_id(uintmax_t *id) WT_GCC_FUNC_ATTRIBUTE((visibility("default"))) { - pthread_t self; + pthread_t self; - /* - * POSIX 1003.1 allows pthread_t to be an opaque type; on systems where - * it's a pointer, print the pointer to match gdb output. - */ - self = pthread_self(); + /* + * POSIX 1003.1 allows pthread_t to be an opaque type; on systems where it's a pointer, print + * the pointer to match gdb output. + */ + self = pthread_self(); #ifdef __sun - *id = (uintmax_t)self; + *id = (uintmax_t)self; #else - *id = (uintmax_t)(void *)self; + *id = (uintmax_t)(void *)self; #endif } /* * __wt_thread_str -- - * Fill in a printable version of the process and thread IDs. + * Fill in a printable version of the process and thread IDs. */ int -__wt_thread_str(char *buf, size_t buflen) - WT_GCC_FUNC_ATTRIBUTE((visibility("default"))) +__wt_thread_str(char *buf, size_t buflen) WT_GCC_FUNC_ATTRIBUTE((visibility("default"))) { - pthread_t self; + pthread_t self; - /* - * POSIX 1003.1 allows pthread_t to be an opaque type; on systems where - * it's a pointer, print the pointer to match gdb output. - */ - self = pthread_self(); + /* + * POSIX 1003.1 allows pthread_t to be an opaque type; on systems where it's a pointer, print + * the pointer to match gdb output. + */ + self = pthread_self(); #ifdef __sun - return (__wt_snprintf(buf, buflen, - "%" PRIuMAX ":%u", (uintmax_t)getpid(), self)); + return (__wt_snprintf(buf, buflen, "%" PRIuMAX ":%u", (uintmax_t)getpid(), self)); #else - return (__wt_snprintf(buf, buflen, - "%" PRIuMAX ":%p", (uintmax_t)getpid(), (void *)self)); + return (__wt_snprintf(buf, buflen, "%" PRIuMAX ":%p", (uintmax_t)getpid(), (void *)self)); #endif } /* * __wt_process_id -- - * Return the process ID assigned by the operating system. + * Return the process ID assigned by the operating system. */ uintmax_t __wt_process_id(void) { - return ((uintmax_t)getpid()); + return ((uintmax_t)getpid()); } |