summaryrefslogtreecommitdiff
path: root/src/slices_evt.c
blob: 917490304acabc2fea4d609a180c5497c8ae76a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//XXX Suprress that when event queue is terminated
#include <stdio.h>
#include <pthread.h>

#include "slices_evt.h"

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 ) {
		switch(res) {
			case 3:
				slicesEvt->eventListener(slicesEvt, initialSlice->next->next);
			case 2:
				slicesEvt->eventListener(slicesEvt, initialSlice->next);
			case 1:
				slicesEvt->eventListener(slicesEvt, initialSlice);
				break;
			default:
				// No events on split errors
				break;
		}
	}
	pthread_mutex_unlock(&(slicesEvt->eventListenerMutex));
	return res;
}

/*
void sliceEvtPutEvent(slices_evt_t *slicesEvt, slice_t *modifiedSlice) {
	printf("sliceEvtPutEvent %p %p\n", slicesEvt, modifiedSlice);
}
*/