1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
/*
FALCON - The Falcon Programming Language.
FILE: vm_sys_win.cpp
System specifics for the falcon VM - POSIX compliant systems.
-------------------------------------------------------------------
Author: Giancarlo Niccolai
Begin: Fri, 25 Apr 2008 17:30:00 +0200
-------------------------------------------------------------------
(C) Copyright 2004: the FALCON developers (see list in AUTHORS file)
See LICENSE file for licensing details.
*/
#include <falcon/vm_sys.h>
#include <falcon/vm_sys_win.h>
#include <falcon/memory.h>
namespace Falcon {
namespace Sys {
SystemData::SystemData(VMachine *vm)
{
m_vm = vm;
m_sysData = (struct VM_SYS_DATA*) memAlloc( sizeof( struct VM_SYS_DATA ) );
// create our interrupting event (a manual reset event)
m_sysData->evtInterrupt = CreateEvent( NULL, TRUE, FALSE, NULL );
}
SystemData::~SystemData()
{
CloseHandle( m_sysData->evtInterrupt );
// delete the structure
memFree( m_sysData );
}
bool SystemData::interrupted() const
{
return WaitForSingleObject( m_sysData->evtInterrupt, 0 ) == WAIT_OBJECT_0;
}
void SystemData::interrupt()
{
SetEvent( m_sysData->evtInterrupt );
}
void SystemData::resetInterrupt()
{
ResetEvent( m_sysData->evtInterrupt );
}
bool SystemData::sleep( numeric seconds ) const
{
return WaitForSingleObject( m_sysData->evtInterrupt, (DWORD) (seconds * 1000.0) ) != WAIT_OBJECT_0;
}
const char *SystemData::getSystemType()
{
return "WIN";
}
bool SystemData::becomeSignalTarget()
{
/* no-op for now */
return true;
}
void SystemData::earlyCleanup()
{
}
}
}
/* end of vm_sys_win.cpp */
|