pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Igor Shevchenko <igor@carcass.ath.cx>
To: pgsql-interfaces@postgresql.org
Subject: libpq/async notifications
Date: Sat, 11 Oct 2003 12:20:25 +0300
Message-ID: <200310111220.25923.igor@carcass.ath.cx> (raw)

Hi

Is there a way to only check if there's any pending async notifications ?
I've found only PQnotifies(..) but it also removes the first notification from 
the list.
A function for only checking this can be used in a gui app to setup async 
notifications processing so it happens only after an app reaches it's main 
loop (which is a good idea since it won't happen in the middle of another 
app's handler function which happens to use pgsql database interface).
Currently I have to check for notifications with PQnotifies every time my app 
returns to the main loop after using any of PGexec, etc, which is not very 
efficient.

The check function is as simple as:

int PQhasNotifies(PGconn *conn)
{
        if (!conn)
                return NULL;

        /* Parse any available data to see if we can extract NOTIFY messages*/
        parseInput(conn);

        return NULL != DLGetHead(conn->notifyList);
}


-- 
Best regards,
Igor Shevchenko




view thread (4+ messages)  latest in thread

Message-ID: <200310111220.25923.igor@carcass.ath.cx>
Permalink:  ../200310111220.25923.igor@carcass.ath.cx/
Also on:    postgresql.org/message-id/200310111220.25923.igor@carcass.ath.cx

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: igor@carcass.ath.cx
  Subject: Re: libpq/async notifications
  In-Reply-To: <200310111220.25923.igor@carcass.ath.cx>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox