Skip to content

Commit

Permalink
fixed sample
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud Bouchez committed Apr 26, 2024
1 parent 27decbb commit 527b3fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions ex/techempower-bench/raw.pas
Expand Up @@ -104,8 +104,7 @@ TRawAsyncServer = class(TSynPersistent)
procedure OnAsyncFortunes(Statement: TSqlDBPostgresAsyncStatement; Context: TObject);
{$endif USE_SQLITE3}
// pipelined reading as used by /rawqueries and /rawupdates
function GetRawRandomWorlds(cnt: PtrInt;
out res: TWorlds; out gen: PLecuyer): boolean;
function GetRawRandomWorlds(cnt: PtrInt; out res: TWorlds): boolean;
function ComputeRawFortunes(stmt: TSqlDBStatement; ctxt: THttpServerRequest): integer;
public
constructor Create(threadCount: integer; flags: THttpServerOptions;
Expand Down Expand Up @@ -313,14 +312,15 @@ procedure TRawAsyncServer.GenerateDB;
// query DB world table for /rawqueries and /rawupdates endpoints

function TRawAsyncServer.GetRawRandomWorlds(cnt: PtrInt;
out res: TWorlds; out gen: PLecuyer): boolean;
out res: TWorlds): boolean;
var
conn: TSqlDBConnection;
stmt: ISqlDBStatement;
{$ifndef USE_SQLITE3}
pConn: TSqlDBPostgresConnection absolute conn;
pStmt: TSqlDBPostgresStatement;
{$endif USE_SQLITE3}
gen: PLecuyer;
i: PtrInt;
begin
result := false;
Expand Down Expand Up @@ -545,9 +545,8 @@ function TRawAsyncServer.rawdb(ctxt: THttpServerRequest): cardinal;
function TRawAsyncServer.rawqueries(ctxt: THttpServerRequest): cardinal;
var
res: TWorlds;
gen: PLecuyer;
begin
if not GetRawRandomWorlds(GetQueriesParamValue(ctxt), res, gen) then
if not GetRawRandomWorlds(GetQueriesParamValue(ctxt), res) then
exit(HTTP_SERVERERROR);
ctxt.SetOutJson(@res, TypeInfo(TWorlds));
result := HTTP_SUCCESS;
Expand Down Expand Up @@ -623,9 +622,10 @@ function TRawAsyncServer.rawupdates(ctxt: THttpServerRequest): cardinal;
result := HTTP_SERVERERROR;
conn := fDbPool.ThreadSafeConnection;
cnt := getQueriesParamValue(ctxt);
if not getRawRandomWorlds(cnt, res, gen) then
if not getRawRandomWorlds(cnt, res) then
exit;
// generate new randoms
gen := Lecuyer;
for i := 0 to cnt - 1 do
res[i].randomNumber := ComputeRandomWorld(gen);
if cnt > 20 then
Expand Down
2 changes: 1 addition & 1 deletion src/mormot.commit.inc
@@ -1 +1 @@
'2.2.7413'
'2.2.7414'

0 comments on commit 527b3fb

Please sign in to comment.