This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unit uWinVMMemoryStream; | |
interface | |
uses | |
Classes, Windows; | |
type | |
TWinVMMemoryStream = class(TMemoryStream) | |
private |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unit TestuWinVMMemoryStream; | |
{ | |
Delphi DUnit Test Case | |
---------------------- | |
This unit contains a skeleton test case class generated by the Test Case Wizard. | |
Modify the generated code to correctly setup and call the methods from the unit | |
being tested. | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Copyright 2013 Convey Compliance Systems, Inc. | |
* | |
* All rights reserved. No warranty, explicit or implicit, provided. | |
*/ | |
#ifndef SVCBUS_THREADPOOL_H | |
#define SVCBUS_THREADPOOL_H | |
#include <Windows.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int SvcBusThreadPoolTimer_init( SvcBusThreadPoolTimer* _this, SvcBusThreadPool* pool, SvcBusThreadPool_callback callback, void* context, unsigned int millis ) | |
{ | |
FILETIME FileDueTime; | |
ULARGE_INTEGER ulDueTime; | |
_this->timer = CreateThreadpoolTimer( &SvcBusThreadPoolTimer_TimerCallback, _this, &pool->pcbe ); | |
if( _this->timer == NULL ) | |
{ | |
return SVCBUS_THREADPOOL_ERROR; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TEST_F(SvcBusThreadPoolTest, SvcBusConsumer_testThreadPoolTimer) { | |
SvcBusThreadPoolTimer timer[1]; | |
int int_value = 0; | |
ASSERT_TRUE(SvcBusThreadPoolTimer_init( timer, thread_pool, &TestCallback, &int_value, 100 ) == SVCBUS_THREADPOOL_OK); | |
EXPECT_EQ(0, SvcBusThreadPoolTimer_getThreadId( timer)); | |
SvcBus_crossSleep(500); | |
EXPECT_TRUE( int_value > 0 ); | |
EXPECT_NE(0, SvcBusThreadPoolTimer_getThreadId( timer)); | |
SvcBusThreadPoolTimer_destroy( timer ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int SvcBusThreadPoolTimer_init( SvcBusThreadPoolTimer* _this, SvcBusThreadPool* pool, SvcBusThreadPool_callback callback, void* context, unsigned int millis ) | |
{ | |
FILETIME FileDueTime; | |
ULARGE_INTEGER ulDueTime; | |
_this->timer = CreateThreadpoolTimer( &SvcBusThreadPoolTimer_TimerCallback, _this, &pool->pcbe ); | |
if( _this->timer == NULL ) | |
{ | |
return SVCBUS_THREADPOOL_ERROR; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unit uWin64ExceptionStack; | |
interface | |
{$IFDEF WIN64} | |
const | |
MAX_NESTED_EXCEPTIONS = 16; | |
type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
The idea of DelphiSwitchToFiber() function is to backup on a local variable in stack the | |
state of the Exception stack right before calling SwitchToFiber() and then restoring its state | |
right atfer returns from call to SwitchToFiber(). | |
If SwitchToFiber() is used directly from within an Except or Finally block, and if there's an exception | |
raised after switching to another fiber, upon coming back the results will be unpredictable because | |
the exception stack will be completely unwinded and all raise exceptions destroyed. | |
In order to prevent this issue we must backup the Exception stack before the call to SwitchToFiber() | |
and restore it right after the call. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
procedure TestTJobQueue.JobMethodRaiseAndSwitchToFiber(const AJob: IJob; const AParams: array of Variant); | |
begin | |
try | |
Check(True); | |
raise ETestJobQueue.Create('Hello'); | |
except | |
on E : Exception do | |
begin | |
try | |
raise ETestJobQueue.Create('Hello Nested'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string> | |
using namespace std; | |
class myString { | |
static int globalCounter; | |
string str; | |
public: | |
int counter; |
OlderNewer