mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 23:58:20 +00:00
Introducing - the check if a thread queue might have data. Without locks. Who needs those anyways.
This commit is contained in:
parent
355b85fcd7
commit
3405cbdfbd
3 changed files with 17 additions and 0 deletions
|
@ -82,6 +82,12 @@ double Manager::NextTimestamp(double* network_time)
|
||||||
// If we had something to process last time (or out heartbeat
|
// If we had something to process last time (or out heartbeat
|
||||||
// is due), we want to check for more asap.
|
// is due), we want to check for more asap.
|
||||||
return timer_mgr->Time();
|
return timer_mgr->Time();
|
||||||
|
|
||||||
|
for ( msg_thread_list::iterator i = msg_threads.begin(); i != msg_threads.end(); i++ )
|
||||||
|
{
|
||||||
|
if ( (*i)->MightHaveOut() )
|
||||||
|
return timer_mgr->Time();
|
||||||
|
}
|
||||||
|
|
||||||
return -1.0;
|
return -1.0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -261,6 +261,12 @@ private:
|
||||||
*/
|
*/
|
||||||
bool HasOut() { return queue_out.Ready(); }
|
bool HasOut() { return queue_out.Ready(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if there might be at least one message pending for the main
|
||||||
|
* thread.
|
||||||
|
*/
|
||||||
|
bool MightHaveOut() { return queue_out.MaybeReady(); }
|
||||||
|
|
||||||
Queue<BasicInputMessage *> queue_in;
|
Queue<BasicInputMessage *> queue_in;
|
||||||
Queue<BasicOutputMessage *> queue_out;
|
Queue<BasicOutputMessage *> queue_out;
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,11 @@ public:
|
||||||
*/
|
*/
|
||||||
bool Ready();
|
bool Ready();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the next Get() operation might succeed.
|
||||||
|
*/
|
||||||
|
bool MaybeReady() { return ( ( read_ptr - write_ptr) != 0 ); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of queued items not yet retrieved.
|
* Returns the number of queued items not yet retrieved.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue