12
12
You should have received a copy of the GNU General Public License
13
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
16
#ifndef PLUGIN_MULTI_THREAD_MULTI_THREAD_H
17
17
#define PLUGIN_MULTI_THREAD_MULTI_THREAD_H
20
20
#include <drizzled/gettext.h>
21
21
#include <drizzled/error.h>
22
22
#include <drizzled/plugin/scheduler.h>
23
#include "drizzled/internal/my_sys.h"
24
23
#include <drizzled/sql_parse.h>
24
#include <drizzled/session.h>
31
namespace multi_thread {
33
27
class MultiThreadScheduler: public drizzled::plugin::Scheduler
36
30
drizzled::atomic<uint32_t> thread_count;
39
34
MultiThreadScheduler(const char *name_arg):
40
35
Scheduler(name_arg)
37
struct sched_param tmp_sched_param;
39
memset(&tmp_sched_param, 0, sizeof(struct sched_param));
41
/* Setup attribute parameter for session threads. */
42
(void) pthread_attr_init(&attr);
43
(void) pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
44
pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
46
tmp_sched_param.sched_priority= WAIT_PRIOR;
47
(void) pthread_attr_setschedparam(&attr, &tmp_sched_param);
46
52
~MultiThreadScheduler();
47
bool addSession(drizzled::Session::shared_ptr &session);
48
void killSessionNow(drizzled::Session::shared_ptr &session);
49
void killSession(drizzled::Session*);
53
bool addSession(Session *session);
54
void killSessionNow(Session *session);
51
void runSession(drizzled::session_id_t);
56
void runSession(Session *session)
60
session->disconnect(ER_OUT_OF_RESOURCES, true);
61
statistic_increment(aborted_connects, &LOCK_status);
62
killSessionNow(session);
65
session->thread_stack= (char*) &session;
67
killSessionNow(session);
56
} // namespace multi_thread
58
71
#endif /* PLUGIN_MULTI_THREAD_MULTI_THREAD_H */