diff options
-rw-r--r-- | inc/slices_evt.h | 6 | ||||
-rw-r--r-- | src/slices_evt.c | 16 |
2 files changed, 18 insertions, 4 deletions
diff --git a/inc/slices_evt.h b/inc/slices_evt.h index e7d44fe..d5772b3 100644 --- a/inc/slices_evt.h +++ b/inc/slices_evt.h @@ -7,11 +7,13 @@ typedef struct _slices_evt_t { slices_t *data; - pthread_mutex_t mutex; void (*eventListener)(/*sliceEvtKind_t evtKind,*/ struct _slices_evt_t *slicesEvt, slice_t *slice); + pthread_mutex_t eventListenerMutex; } slices_evt_t; -int sliceSplitEvt(slices_evt_t *slicesEvt, slice_t *initialSlice, address_t splitAt, sliceStatus_t statusBefore, sliceStatus_t statusAt, sliceStatus_t statusAfter); +int sliceEvtSplit(slices_evt_t *slicesEvt, slice_t *initialSlice, address_t splitAt, sliceStatus_t statusBefore, sliceStatus_t statusAt, sliceStatus_t statusAfter); + +//void sliceEvtPutEvent(slices_evt_t *slicesEvt, slice_t *modifiedSlice); #endif /*SLICES_EVT_H */ diff --git a/src/slices_evt.c b/src/slices_evt.c index 43cb568..9174903 100644 --- a/src/slices_evt.c +++ b/src/slices_evt.c @@ -1,10 +1,15 @@ +//XXX Suprress that when event queue is terminated +#include <stdio.h> +#include <pthread.h> + #include "slices_evt.h" -int sliceSplitEvt(slices_evt_t *slicesEvt, slice_t *initialSlice, address_t splitAt, sliceStatus_t statusBefore, sliceStatus_t statusAt, sliceStatus_t statusAfter) { +int sliceEvtSplit(slices_evt_t *slicesEvt, slice_t *initialSlice, address_t splitAt, sliceStatus_t statusBefore, sliceStatus_t statusAt, sliceStatus_t statusAfter) { int res; res=sliceSplit(slicesEvt->data, initialSlice, splitAt, statusBefore, statusAt, statusAfter); + + pthread_mutex_lock(&(slicesEvt->eventListenerMutex)); if ( slicesEvt->eventListener != NULL ) { - //FIXME : this could be dereference a NULL pointer. Implement a real listener system with a thread-safe FIFO switch(res) { case 3: slicesEvt->eventListener(slicesEvt, initialSlice->next->next); @@ -18,5 +23,12 @@ int sliceSplitEvt(slices_evt_t *slicesEvt, slice_t *initialSlice, address_t spli break; } } + pthread_mutex_unlock(&(slicesEvt->eventListenerMutex)); return res; } + +/* +void sliceEvtPutEvent(slices_evt_t *slicesEvt, slice_t *modifiedSlice) { + printf("sliceEvtPutEvent %p %p\n", slicesEvt, modifiedSlice); +} +*/ |