Browse Source
Revert "first try for a threaded event dispatcher, but this is not correctly working right now."
Revert "first try for a threaded event dispatcher, but this is not correctly working right now."
This reverts commit fcbef2f039.
1.0.0
12 changed files with 22 additions and 287 deletions
-
3include/Makefile.am
-
13include/tr/event_dispatcher.h
-
44include/tr/event_thread.h
-
1include/trevent.h
-
5src/Makefile.am
-
9src/event_dispatcher.c
-
26src/event_dispatcher_start.c
-
21src/event_handler_handle_event.c
-
9src/event_handler_issue_event.c
-
56src/event_thread.c
-
65src/event_thread_join.c
-
57src/event_thread_start.c
@ -1,44 +0,0 @@ |
|||||
/** |
|
||||
* \file |
|
||||
* |
|
||||
* \author Georg Hopp |
|
||||
* |
|
||||
* \copyright |
|
||||
* Copyright © 2014 Georg Hopp |
|
||||
* |
|
||||
* This program is free software: you can redistribute it and/or modify |
|
||||
* it under the terms of the GNU General Public License as published by |
|
||||
* the Free Software Foundation, either version 3 of the License, or |
|
||||
* (at your option) any later version. |
|
||||
* |
|
||||
* This program is distributed in the hope that it will be useful, |
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
* GNU General Public License for more details. |
|
||||
* |
|
||||
* You should have received a copy of the GNU General Public License |
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
||||
*/ |
|
||||
|
|
||||
#ifndef __TR_EVENT_THREAD_H__ |
|
||||
#define __TR_EVENT_THREAD_H__ |
|
||||
|
|
||||
#include <pthread.h> |
|
||||
|
|
||||
#include "trbase.h" |
|
||||
#include "event_dispatcher.h" |
|
||||
|
|
||||
TR_CLASS(TR_EventThread) { |
|
||||
TR_EventDispatcher dispatcher; |
|
||||
pthread_t handle; |
|
||||
}; |
|
||||
TR_INSTANCE_INIT(TR_EventThread); |
|
||||
TR_CLASSVARS_DECL(TR_EventThread) {}; |
|
||||
|
|
||||
void TR_eventThreadStart(TR_EventThread); |
|
||||
void TR_eventThreadJoin(TR_EventThread); |
|
||||
|
|
||||
#endif // __TR_EVENT_THREAD_H__ |
|
||||
|
|
||||
// vim: set ts=4 sw=4: |
|
||||
|
|
||||
@ -1,56 +0,0 @@ |
|||||
/** |
|
||||
* \file |
|
||||
* |
|
||||
* \author Georg Hopp |
|
||||
* |
|
||||
* \copyright |
|
||||
* Copyright © 2014 Georg Hopp |
|
||||
* |
|
||||
* This program is free software: you can redistribute it and/or modify |
|
||||
* it under the terms of the GNU General Public License as published by |
|
||||
* the Free Software Foundation, either version 3 of the License, or |
|
||||
* (at your option) any later version. |
|
||||
* |
|
||||
* This program is distributed in the hope that it will be useful, |
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
* GNU General Public License for more details. |
|
||||
* |
|
||||
* You should have received a copy of the GNU General Public License |
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
||||
*/ |
|
||||
|
|
||||
#include <pthread.h> |
|
||||
|
|
||||
#include "trbase.h" |
|
||||
|
|
||||
#include "tr/event_dispatcher.h" |
|
||||
#include "tr/event_thread.h" |
|
||||
|
|
||||
static |
|
||||
int |
|
||||
eventThreadCtor(void * _this, va_list * params) |
|
||||
{ |
|
||||
TR_EventThread this = _this; |
|
||||
|
|
||||
this->dispatcher = va_arg(*params, TR_EventDispatcher); |
|
||||
|
|
||||
return 0; |
|
||||
} |
|
||||
|
|
||||
static |
|
||||
void |
|
||||
eventThreadDtor(void * _this) |
|
||||
{ |
|
||||
TR_EventThread this = _this; |
|
||||
|
|
||||
if (this->handle) { |
|
||||
pthread_cancel(this->handle); |
|
||||
pthread_join(this->handle, NULL); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
TR_INIT_IFACE(TR_Class, eventThreadCtor, eventThreadDtor, NULL); |
|
||||
TR_CREATE_CLASS(TR_EventThread, NULL, NULL, TR_IF(TR_Class)); |
|
||||
|
|
||||
// vim: set ts=4 sw=4: |
|
||||
@ -1,65 +0,0 @@ |
|||||
/** |
|
||||
* \file |
|
||||
* |
|
||||
* \author Georg Hopp |
|
||||
* |
|
||||
* \copyright |
|
||||
* Copyright © 2014 Georg Hopp |
|
||||
* |
|
||||
* This program is free software: you can redistribute it and/or modify |
|
||||
* it under the terms of the GNU General Public License as published by |
|
||||
* the Free Software Foundation, either version 3 of the License, or |
|
||||
* (at your option) any later version. |
|
||||
* |
|
||||
* This program is distributed in the hope that it will be useful, |
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
* GNU General Public License for more details. |
|
||||
* |
|
||||
* You should have received a copy of the GNU General Public License |
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
||||
*/ |
|
||||
|
|
||||
#include <pthread.h> |
|
||||
#include <errno.h> |
|
||||
|
|
||||
#include "trbase.h" |
|
||||
|
|
||||
#include "tr/event_thread.h" |
|
||||
|
|
||||
void |
|
||||
TR_eventThreadJoin(TR_EventThread this) |
|
||||
{ |
|
||||
int error = pthread_join(this->handle, NULL); |
|
||||
|
|
||||
/* |
|
||||
* AFAIC there is no error condition from this function that |
|
||||
* should lead to a retry. Additionally pthread_join is |
|
||||
* continued after a signal, so all I do is log error and |
|
||||
* continue with the next. |
|
||||
*/ |
|
||||
switch (error) { |
|
||||
case EDEADLK: |
|
||||
TR_loggerLog( |
|
||||
TR_logger, |
|
||||
TR_LOGGER_WARNING, |
|
||||
"Thread deadlock detected"); |
|
||||
break; |
|
||||
|
|
||||
case EINVAL: |
|
||||
TR_loggerLog( |
|
||||
TR_logger, |
|
||||
TR_LOGGER_WARNING, |
|
||||
"Tried to join a non joinable thread"); |
|
||||
break; |
|
||||
|
|
||||
case ESRCH: |
|
||||
TR_loggerLog( |
|
||||
TR_logger, |
|
||||
TR_LOGGER_WARNING, |
|
||||
"Tried to join non existent thread"); |
|
||||
break; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
// vim: set ts=4 sw=4: |
|
||||
@ -1,57 +0,0 @@ |
|||||
/** |
|
||||
* \file |
|
||||
* |
|
||||
* \author Georg Hopp |
|
||||
* |
|
||||
* \copyright |
|
||||
* Copyright © 2014 Georg Hopp |
|
||||
* |
|
||||
* This program is free software: you can redistribute it and/or modify |
|
||||
* it under the terms of the GNU General Public License as published by |
|
||||
* the Free Software Foundation, either version 3 of the License, or |
|
||||
* (at your option) any later version. |
|
||||
* |
|
||||
* This program is distributed in the hope that it will be useful, |
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
* GNU General Public License for more details. |
|
||||
* |
|
||||
* You should have received a copy of the GNU General Public License |
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
||||
*/ |
|
||||
|
|
||||
#include <pthread.h> |
|
||||
|
|
||||
#include "trbase.h" |
|
||||
|
|
||||
#include "tr/event_dispatcher.h" |
|
||||
#include "tr/event_thread.h" |
|
||||
|
|
||||
static |
|
||||
void * |
|
||||
TR_eventStreadRun(void * message) |
|
||||
{ |
|
||||
TR_EventThread this = message; |
|
||||
TR_eventDispatcherStart(this->dispatcher); |
|
||||
return NULL; |
|
||||
} |
|
||||
|
|
||||
void |
|
||||
TR_eventThreadStart(TR_EventThread this) |
|
||||
{ |
|
||||
int error = pthread_create( |
|
||||
&this->handle, |
|
||||
NULL, |
|
||||
TR_eventStreadRun, |
|
||||
(void *)this); |
|
||||
|
|
||||
if (error) { |
|
||||
TR_loggerLog( |
|
||||
TR_logger, |
|
||||
TR_LOGGER_ERR, |
|
||||
"Thread creation failed with error code: %d", |
|
||||
error); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
// vim: set ts=4 sw=4: |
|
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue