blob: 359094072920cea9981bcb57a1387b825de9cafd [file] [log] [blame]
Ernesto Posse8a4f2962015-05-12 13:28:46 -04001// umlrtmessage.cc
2
3/*******************************************************************************
4* Copyright (c) 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#include "umlrtapi.hh"
12#include "umlrtcontroller.hh"
13#include "umlrtmessage.hh"
14#include "umlrtqueue.hh"
15
16// See umlrtmessagequeue.hh for documentation.
17
18bool UMLRTMessage::defer() const
19{
20 bool ok = false;
21
22 UMLRTMessage * msg = umlrt::MessageGetFromPool();
23 if (msg == NULL)
24 {
25 destPort->slot->controller->setError(UMLRTController::E_DEFER_ALLOC);
26 }
27 else
28 {
29 msg->srcPortIndex = srcPortIndex;
30 msg->sapIndex0 = sapIndex0;
31 msg->destPort = destPort;
32 msg->destSlot = destSlot;
33 msg->signal = signal; // This copy causes the reference count on signal to increment.
34 msg->isCommand = isCommand;
35
36 // Append to defer queue.
37 destPort->deferQueue->enqueue(msg);
38 ok = true;
39 }
40 return ok;
41}
42