Project

General

Profile

Statistics
| Branch: | Revision:

root / src / sim / cparsimcomm.cc @ 3e29b8a0

History | View | Annotate | Download (1.58 KB)

1 01873262 Georg Kunz
//=========================================================================
2
//  CPARCOMM.CC - part of
3
//
4
//                  OMNeT++/OMNEST
5
//           Discrete System Simulation in C++
6
//
7
//  Author: Andras Varga, 2003
8
//
9
//=========================================================================
10
11
/*--------------------------------------------------------------*
12
  Copyright (C) 2003-2008 Andras Varga
13
  Copyright (C) 2006-2008 OpenSim Ltd.
14
  Monash University, Dept. of Electrical and Computer Systems Eng.
15
  Melbourne, Australia
16

17
  This file is distributed WITHOUT ANY WARRANTY. See the file
18
  `license' for details on this and other legal matters.
19
*--------------------------------------------------------------*/
20
21
#include <stdlib.h>
22
#include <stdio.h>
23
#include "errmsg.h"
24
#include "ccommbuffer.h"
25
#include "cparsimcomm.h"
26
#include "cenvir.h"
27
#include "cexception.h"
28
29
USING_NAMESPACE
30
31
32
void cParsimCommunications::broadcast(cCommBuffer *buffer, int tag)
33
{
34
    // Default implementation: send to everyone. Try to do as much of the job
35
    // as possible -- if there're exceptions, throw on only one of them.
36
    bool hadException = false;
37
    std::string exceptionText;
38
39
    int n = getNumPartitions();
40
    int myProcId = getProcId();
41
    for (int i=0; i<n; i++)
42
    {
43
        try
44
        {
45
            if (myProcId != i)
46
                send(buffer, tag, i);
47
        }
48
        catch (std::exception& e)
49
        {
50
            hadException = true;
51
            exceptionText = e.what();
52
        }
53
    }
54
55
    if (hadException)
56
        throw cRuntimeError("Error during broadcast: %s", exceptionText.c_str());
57
}
58