@@ -471,6 +471,8 @@ TAsyncConnectionsThread = class(TSynThread)
471
471
// - acoThreadSmooting will change the ThreadPollingWakeup() algorithm to
472
472
// focus the process on the first threads of the pool - by design, this
473
473
// setting will disable both acoThreadCpuAffinity and acoThreadSocketAffinity
474
+ // - acoEventFD (on Linux only) will use eventfd() instead of futexes to
475
+ // notify the processing threads - by design, will disable acoThreadSmooting
474
476
TAsyncConnectionsOptions = set of (
475
477
acoOnErrorContinue,
476
478
acoNoLogRead,
@@ -483,7 +485,8 @@ TAsyncConnectionsThread = class(TSynThread)
483
485
acoThreadCpuAffinity,
484
486
acoThreadSocketAffinity,
485
487
acoReusePort,
486
- acoThreadSmooting
488
+ acoThreadSmooting,
489
+ acoEventFD
487
490
);
488
491
489
492
// / to implement generational garbage collector of asynchronous connections
@@ -1843,10 +1846,7 @@ procedure TAsyncConnectionsThread.Execute;
1843
1846
// fOwner.fClients.fRead.PendingLogDebug('Wakeup');
1844
1847
fEvent.ResetEvent;
1845
1848
fWaitForReadPending := true; // should be set before wakeup
1846
- if Assigned(fOwner.fThreadPollingEventFD) then
1847
- fOwner.fThreadPollingEventFD.SetEvent(new)
1848
- else
1849
- fOwner.ThreadPollingWakeup(pending);
1849
+ fOwner.ThreadPollingWakeup(new);
1850
1850
// fOwner.DoLog(sllCustom1, 'Execute: WaitFor ReadPending', [], self);
1851
1851
if not Terminated then
1852
1852
fEvent.WaitFor(20 );
@@ -1978,7 +1978,8 @@ constructor TAsyncConnections.Create(const OnStart, OnStop: TOnNotifyThread;
1978
1978
// prepare this main thread: fThreads[] requires proper fOwner.OnStart/OnStop
1979
1979
inherited Create({ suspended=} false, OnStart, OnStop, ProcessName);
1980
1980
// initiate the read/receive thread(s)
1981
- // fThreadPollingEventFD := NewEventFD; // nil if unsupported
1981
+ if acoEventFD in aOptions then
1982
+ fThreadPollingEventFD := NewEventFD; // nil if unsupported
1982
1983
fThreadPoolCount := aThreadPoolCount;
1983
1984
SetLength(fThreads, fThreadPoolCount);
1984
1985
if aThreadPoolCount = 1 then
@@ -3528,7 +3529,10 @@ constructor THttpAsyncServer.Create(const aPort: RawUtf8;
3528
3529
// include(aco, acoWritePollOnly);
3529
3530
if hsoEnableTls in ProcessOptions then
3530
3531
include(aco, acoEnableTls);
3531
- if hsoThreadSmooting in ProcessOptions then
3532
+ if (hsoEventFD in ProcessOptions) and
3533
+ (NewEventFD <> nil ) then // try to allocate a temporary eventfd() instance
3534
+ include(aco, acoEventFD) // and exclude other options
3535
+ else if hsoThreadSmooting in ProcessOptions then
3532
3536
include(aco, acoThreadSmooting) // and exclude any thread affinity
3533
3537
else
3534
3538
begin
0 commit comments