blob: bf43bad5cae9427e6c4ed900f5fa4616fa5f9929 [file] [log] [blame]
Ernesto Posse8a4f2962015-05-12 13:28:46 -04001// umlrttimerpool.cc
2
3/*******************************************************************************
4 * Copyright (c) 2014-2015 Zeligsoft (2009) Limited and others.
5 * All rights reserved. This program and the accompanying materials
6 * are made available under the terms of the Eclipse Public License v1.0
7 * which accompanies this distribution, and is available at
8 * http://www.eclipse.org/legal/epl-v10.html
9 *******************************************************************************/
10
11// See umlrttimer.hh for documentation.
12#include <stdlib.h>
13#include "basefatal.hh"
14#include "umlrttimerpool.hh"
15#include "umlrtguard.hh"
16
17UMLRTTimerPool::UMLRTTimerPool(UMLRTTimer timerElements[], size_t arraySize, size_t incrementSize) :
18 UMLRTPool(incrementSize)
19{
20 UMLRTGuard g(mutex);
21
22 if (arraySize && timerElements != NULL)
23 {
24 for (size_t i = arraySize - 1; i > 0; --i)
25 {
26 timerElements[i - 1].next = &timerElements[i];
27 timerElements[i - 1].qid = qid++;
28 }
29 head = &timerElements[0];
30 }
31}
32
33UMLRTTimerPool::UMLRTTimerPool(size_t incrementSize) :
34 UMLRTPool(incrementSize)
35{
36
37}
38
39void UMLRTTimerPool::grow()
40{
41 UMLRTTimer * newElements = new UMLRTTimer[increment]();
42
43 for (size_t i = increment - 1; i > 0; --i)
44 {
45 newElements[i - 1].next = &newElements[i];
46 }
47 newElements[increment - 1].next = head;
48 head = &newElements[0];
49}
50