1 /*
2 * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2.0,
6 * as published by the Free Software Foundation.
7 *
8 * This program is also distributed with certain software (including
9 * but not limited to OpenSSL) that is licensed under separate terms,
10 * as designated in a particular file or component or in included license
11 * documentation. The authors of MySQL hereby grant you an additional
12 * permission to link the program and your derivative works with the
13 * separately licensed software that they have included with MySQL.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License, version 2.0, for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
25 #include "plugin/x/ngs/include/ngs/thread.h"
26
27 #include <stdexcept>
28
29 #include "my_sys.h" // my_thread_stack_size
30 #include "my_thread.h"
31
thread_create(PSI_thread_key key MY_ATTRIBUTE ((unused)),Thread_t * thread,Start_routine_t func,void * arg)32 void ngs::thread_create(PSI_thread_key key MY_ATTRIBUTE((unused)),
33 Thread_t *thread, Start_routine_t func, void *arg) {
34 my_thread_attr_t connection_attrib;
35
36 (void)my_thread_attr_init(&connection_attrib);
37 /*
38 check_stack_overrun() assumes that stack size is (at least)
39 my_thread_stack_size. If it is smaller, we may segfault.
40 */
41 my_thread_attr_setstacksize(&connection_attrib, my_thread_stack_size);
42
43 if (mysql_thread_create(key, thread, &connection_attrib, func, arg))
44 throw std::runtime_error("Could not create a thread");
45 }
46
thread_join(Thread_t * thread,void ** ret)47 int ngs::thread_join(Thread_t *thread, void **ret) {
48 return my_thread_join(thread, ret);
49 }
50