realTime

Purpose

This simple behaviour pauses the VCC simulation thread for 20ms after a simulated Await() of 0.1. Without this behaviour the VCC thread will monopolise the CPU time.
It should be included once at the top level.

VCC Symbol

Code

realTime: black.h

#include "black_interface.h" //generated by "fabricate"
#ifndef _realTime_h_
#define _realTime_h_

class CPP_MODEL_IMPLEMENTATION : public CPP_MODEL_INTERFACE
{
public:
CPP_MODEL_IMPLEMENTATION(const ModuleProto &, InstanceInit &);

  void Init();

  void Run();
}
;

#endif

 

realTime: black.cpp

#include "black.h"
#include "windows.h"

CPP_MODEL_IMPLEMENTATION::CPP_MODEL_IMPLEMENTATION(const ModuleProto &proto, InstanceInit &inst)
: CPP_MODEL_INTERFACE(proto, inst)
{}

void CPP_MODEL_IMPLEMENTATION::Init()
{}

void CPP_MODEL_IMPLEMENTATION::Run()
{
  while(true){
    Sleep(20);
    Await(0.1);
  }
}


Copyright © 2002 James Brown
Last Updated Fri, 3/5/02