View | Details | Raw Unified | Return to bug 2203
Collapse All | Expand All

(-)a/src/core/examples/sample-simulator.cc (+7 lines)
 Lines 24-29    Link Here 
24
#include "ns3/command-line.h"
24
#include "ns3/command-line.h"
25
#include "ns3/double.h"
25
#include "ns3/double.h"
26
#include "ns3/random-variable-stream.h"
26
#include "ns3/random-variable-stream.h"
27
#include "ns3/make-functional-event.h"
27
28
28
/**
29
/**
29
 * \file
30
 * \file
 Lines 110-115    Link Here 
110
  EventId id = Simulator::Schedule (Seconds (30.0), &CancelledEvent);
111
  EventId id = Simulator::Schedule (Seconds (30.0), &CancelledEvent);
111
  Simulator::Cancel (id);
112
  Simulator::Cancel (id);
112
113
114
  Simulator::Schedule (Seconds (25.0), MakeFunctionalEvent (
115
    [] ()->void 
116
    {
117
      std::cout << "Code within a lambda expression at time " << Simulator::Now ().GetSeconds () << std::endl;
118
    }));
119
113
  Simulator::Run ();
120
  Simulator::Run ();
114
121
115
  Simulator::Destroy ();
122
  Simulator::Destroy ();
(-)1b6479774454 (+35 lines)
Added Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
3
#ifndef MAKE_FUNCTIONAL_EVENT_H
4
#define MAKE_FUNCTIONAL_EVENT_H
5
6
#include <ns3/event-impl.h>
7
8
namespace ns3 {
9
10
template <typename T>
11
EventImpl * MakeFunctionalEvent (T function)
12
{
13
  class EventMemberImplFunctional : public EventImpl
14
  {
15
public:
16
    EventMemberImplFunctional (T function)
17
      : m_function (function)
18
    {
19
    }
20
    virtual ~EventMemberImplFunctional ()
21
    {
22
    }
23
private:
24
    virtual void Notify (void)
25
    {
26
      m_function();
27
    }
28
    T m_function;
29
  } *ev = new EventMemberImplFunctional (function);
30
  return ev;
31
}
32
33
} // namespace ns3
34
35
#endif /* MAKE_FUNCTIONAL_EVENT_H */
(-)a/src/core/wscript (+1 lines)
 Lines 236-241    Link Here 
236
        'model/watchdog.h',
236
        'model/watchdog.h',
237
        'model/synchronizer.h',
237
        'model/synchronizer.h',
238
        'model/make-event.h',
238
        'model/make-event.h',
239
        'model/make-functional-event.h',
239
        'model/system-wall-clock-ms.h',
240
        'model/system-wall-clock-ms.h',
240
        'model/empty.h',
241
        'model/empty.h',
241
        'model/callback.h',
242
        'model/callback.h',

Return to bug 2203