@@ -45,23 +45,20 @@ public PostgreSqlJobQueue(PostgreSqlStorage storage, PostgreSqlStorageOptions op
4545 _storage = storage ?? throw new ArgumentNullException ( nameof ( storage ) ) ;
4646 SignalDequeue = new AutoResetEvent ( false ) ;
4747 }
48- public PostgreSqlJobQueue ( PostgreSqlStorage storage , PostgreSqlStorageOptions options )
49- {
50- _options = options ?? throw new ArgumentNullException ( nameof ( options ) ) ;
51- _storage = storage ?? throw new ArgumentNullException ( nameof ( storage ) ) ;
52- }
5348
49+ [ NotNull ]
50+ public IFetchedJob Dequeue ( string [ ] queues , CancellationToken cancellationToken )
51+ {
52+ if ( _options . UseNativeDatabaseTransactions )
53+ return Dequeue_Transaction ( queues , cancellationToken ) ;
5454
55- [ NotNull ]
56- public IFetchedJob Dequeue ( string [ ] queues , CancellationToken cancellationToken )
57- {
58- if ( _options . UseNativeDatabaseTransactions )
59- return Dequeue_Transaction ( queues , cancellationToken ) ;
55+ return Dequeue_UpdateCount ( queues , cancellationToken ) ;
56+ }
6057
61- /// <summary>
62- /// Signal the waiting Thread to lookup a new Job
63- /// </summary>
64- public void FetchNextJob ( )
58+ /// <summary>
59+ /// Signal the waiting Thread to lookup a new Job
60+ /// </summary>
61+ public void FetchNextJob ( )
6562 {
6663 SignalDequeue . Set ( ) ;
6764 }
@@ -233,7 +230,13 @@ internal IFetchedJob Dequeue_UpdateCount(string[] queues, CancellationToken canc
233230 {
234231 if ( currentQueryIndex == fetchConditions . Length - 1 )
235232 {
236- cancellationToken . WaitHandle . WaitOne ( _options . QueuePollInterval ) ;
233+ WaitHandle . WaitAny ( new [ ]
234+ {
235+ cancellationToken . WaitHandle ,
236+ SignalDequeue
237+ } ,
238+ _options . QueuePollInterval ) ;
239+
237240 cancellationToken . ThrowIfCancellationRequested ( ) ;
238241 }
239242 }
0 commit comments