1 /***************************************************************************
3 * Copyright 2013 BMW Car IT GmbH
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 ****************************************************************************/
22 #include "ilm_configuration.h"
23 #include "ilm_types.h"
25 #include <semaphore.h>
28 *=============================================================================
29 * Implementation of thread-safe circular queue for local use
30 *=============================================================================
34 pthread_mutex_t queueMutex;
35 sem_t readBlockSemaphore;
42 t_ilm_message* messages;
45 extern t_ilm_msg_queue notificationQueue;
46 extern t_ilm_msg_queue incomingQueue;
47 extern pthread_mutex_t gSendReceiveLock;
49 void init_msg_queue(t_ilm_msg_queue* pQueue, t_ilm_uint maxSize);
50 t_ilm_bool msg_enqueue(t_ilm_msg_queue* pQueue, t_ilm_message message);
51 t_ilm_message msg_dequeue(t_ilm_msg_queue* pQueue);
52 void destroy_msg_queue(t_ilm_msg_queue* pQueue);
55 *=============================================================================
56 * notification callback management
57 *=============================================================================
62 layerNotificationFunc callback;
65 struct SurfaceCallback
68 surfaceNotificationFunc callback;
71 void initNotificationCallbacks();
72 layerNotificationFunc getLayerNotificationCallback(t_ilm_layer layer);
73 surfaceNotificationFunc getSurfaceNotificationCallback(t_ilm_surface surface);
74 t_ilm_bool findLayerCallback(t_ilm_layer layer);
75 t_ilm_bool addLayerCallback(t_ilm_layer layer, layerNotificationFunc func);
76 t_ilm_bool findSurfaceCallback(t_ilm_surface surface);
77 t_ilm_bool addSurfaceCallback(t_ilm_surface surface, surfaceNotificationFunc func);
78 void removeLayerCallback(t_ilm_layer layer);
79 void removeSurfaceCallback(t_ilm_surface layer);
82 *=============================================================================
83 * internal thread management
84 *=============================================================================
86 void* notificationThreadLoop(void* param);
87 void* receiveThreadLoop(void* param);
90 *=============================================================================
91 * receive with timeout
92 *=============================================================================
94 void calculateTimeout(struct timeval* currentTime, int giventimeout, struct timespec* timeout);
95 t_ilm_bool sendAndWaitForResponse(t_ilm_message command, t_ilm_message* response, int timeoutInMs, ilmErrorTypes* error);
97 #endif /* _ILM_TOOLS_H_ */