Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schuetz2013-01-04 16:16:07 +0000
committerThomas Schuetz2013-01-04 16:16:07 +0000
commitd098da1cde5c178c682c57533e514b3e4976250e (patch)
treecea8f78fe0090de6d3f38f80a36aa5dcf075e981 /runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c
parentec0a83ccb44871498c61260c961a911ec2663531 (diff)
downloadorg.eclipse.etrice-d098da1cde5c178c682c57533e514b3e4976250e.tar.gz
org.eclipse.etrice-d098da1cde5c178c682c57533e514b3e4976250e.tar.xz
org.eclipse.etrice-d098da1cde5c178c682c57533e514b3e4976250e.zip
[runtime.c , generator.c.reference] first running version of C reference
code with new runtime API - synchronization does not work yet! Change-Id: Ib37b1a0ea7f3d790cb655d68240c36fe9840dc98
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c')
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c41
1 files changed, 38 insertions, 3 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c
index 3755d2107..59e205e99 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c
@@ -17,20 +17,55 @@
#include "debugging/etLogger.h"
#include "debugging/etMSCLogger.h"
+
+
+/*
+ * initialize message service with all needed data and initialize message queue and message pool
+ *
+ */
void etMessageService_init(etMessageService* self, etUInt8* buffer, etUInt16 maxBlocks, etUInt16 blockSize, etDispatcherReceiveMessage msgDispatcher){
ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "init")
+
+ /* copy init data to self */
self->messageBuffer.buffer = buffer;
self->messageBuffer.maxBlocks = maxBlocks;
self->messageBuffer.blockSize = blockSize;
self->msgDispatcher = msgDispatcher;
- etMessageQueue_init(&self->messagePool);
- etMessageQueue_init(&self->messageQueue);
-
+ /* copy init queue and pool */
+ etMessageQueue_init( &(self->messagePool) ); /* the pool is also a queue*/
+ etMessageQueue_init( &(self->messageQueue) );
etMessageService_initMessagePool(self);
+
+ /* init mutexes and semaphores */
+ etMutex_construct( &(self->poolMutex) );
+ etMutex_construct( &(self->queueMutex) );
+ etSema_construct( &(self->executionSemaphore) );
+
ET_MSC_LOGGER_SYNC_EXIT
}
+void etMessageService_start(etMessageService* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "start")
+ etThread_construct( &(self->thread) );
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etMessageService_stop(etMessageService* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "stop")
+ etThread_destruct( &(self->thread) );
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etMessageService_destroy(etMessageService* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "destroy")
+ etMutex_destruct( &(self->poolMutex) );
+ etMutex_destruct( &(self->queueMutex) );
+ etSema_destruct( &(self->executionSemaphore) );
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+
/*
* initialize message pool with block buffer
* all blocks are added to pool

Back to the top