Re: [sqlite] sqlite3_interrupt() and threads

2006-07-26 Thread Jens Miltner


Am 26.07.2006 um 01:06 schrieb [EMAIL PROTECTED]:


Michael Scharf [EMAIL PROTECTED] wrote:

Rob,
I notice in the documentation that the sqlite3_progress_handler()  
method

is marked experimental.  Is that significant?


No idea, that's a question Richard Hipp may answer..



I need to remove the experimental marking.  Perhaps
somebody could create a ticket to remind me ;-)

While you are at it, consider creating an enhancement
ticket to allow sqlite3_interrupt to be called from
a different thread.


Tickets #1897 and #1898.
I saw that you already committed code to make sqlite3_interrupt  
thread-safe, but created a ticket anyway to make sure it's tracked.


/jum



[sqlite] sqlite3_interrupt() and threads

2006-07-25 Thread Rob Richardson
Greetings!

My application will occasionally be called on to execute queries that
take several minutes.  This will be done from a worker thread so that
the user interface remains active.  As the query is being executed, the
user must be able to respond to alarms.  When the user hits F11 to go
straight to the alarm screen, the window from which the thread that is
running the long query disappears.  However, the thread continues.  I
need to stop the query.  

The thing that takes the time is the first call to sqlite3_step().  That
step is likely to take 5 minutes, and I may need to stop it after 1
minute.  The only way I can think of to do that is to call
sqlite3_interrupt() from a different thread.  However, for regular data
access operations, we can't use the same database connection in two
different threads.  Can sqlite3_interrupt() be called from a different
thread than the sqlite3_step() that I want to interrupt, or is there
some other mechanism I can use, or is there no way to do this?

Thanks very much!

Rob Richardson
Rad-Con, Inc.


Re: [sqlite] sqlite3_interrupt() and threads

2006-07-25 Thread Martin Jenkins

Rob Richardson wrote:


[...] Can sqlite3_interrupt() be called from a different
thread than the sqlite3_step() that I want to interrupt, or is there
some other mechanism I can use, or is there no way to do this?


This came up a couple of weeks ago. I don't have the message here to 
quote but you can see it at:


http://www.mail-archive.com/sqlite-users@sqlite.org/msg16361.html

Martin


RE: [sqlite] sqlite3_interrupt() and threads

2006-07-25 Thread Rob Richardson
Thank you for pointing me to that article.  That leads to two more
questions:  

What alternative do I have?  If I abort the thread that is running the
query, will the query stop?

And, if sqlite3_interrupt() has to be issued from the same thread that
is using the database, what is it designed to be used for?  

OK, three questions:  Is there a way to run sqlite3 queries
asynchronously?

Thanks again!

Rob Richardson
Rad-Con, Inc.


Re: [sqlite] sqlite3_interrupt() and threads

2006-07-25 Thread Michael Scharf

Hi Richard,

I use a progres_handler:
  http://www.sqlite.org/capi3ref.html#sqlite3_progress_handler
I set it up to be called every 1 ticks (2nd argument) or so and
I use and the void* to points to a data structure that contains a
boolean isCanceled. If another thread wants to cancel the worker
thread it sets the isCanceled to true. The progress callback checks
the isCanceled and returns 0 if set. Then the query gets aborted...
(I'm using this in java and it works just fine)


Michael




Thank you for pointing me to that article.  That leads to two more
questions:  


What alternative do I have?  If I abort the thread that is running the
query, will the query stop?

And, if sqlite3_interrupt() has to be issued from the same thread that
is using the database, what is it designed to be used for?  


OK, three questions:  Is there a way to run sqlite3 queries
asynchronously?

Thanks again!

Rob Richardson
Rad-Con, Inc.





--
http://MichaelScharf.blogspot.com/



RE: [sqlite] sqlite3_interrupt() and threads

2006-07-25 Thread Rob Richardson
Great!  That looks like exactly what I need.

Thanks very much!

Rob Richardson
RAD-CON INC.

-Original Message-
From: Michael Scharf [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 25, 2006 10:45 AM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] sqlite3_interrupt() and threads

Hi Richard,

I use a progres_handler:
   http://www.sqlite.org/capi3ref.html#sqlite3_progress_handler
I set it up to be called every 1 ticks (2nd argument) or so and
I use and the void* to points to a data structure that contains a
boolean isCanceled. If another thread wants to cancel the worker
thread it sets the isCanceled to true. The progress callback checks
the isCanceled and returns 0 if set. Then the query gets aborted...
(I'm using this in java and it works just fine)


Michael



 Thank you for pointing me to that article.  That leads to two more
 questions:  
 
 What alternative do I have?  If I abort the thread that is running the
 query, will the query stop?
 
 And, if sqlite3_interrupt() has to be issued from the same thread that
 is using the database, what is it designed to be used for?  
 
 OK, three questions:  Is there a way to run sqlite3 queries
 asynchronously?
 
 Thanks again!
 
 Rob Richardson
 Rad-Con, Inc.
 
 


-- 
http://MichaelScharf.blogspot.com/



RE: [sqlite] sqlite3_interrupt() and threads

2006-07-25 Thread Rob Richardson
Michael,

I notice in the documentation that the sqlite3_progress_handler() method
is marked experimental.  Is that significant?

Rob


Re: [sqlite] sqlite3_interrupt() and threads

2006-07-25 Thread Michael Scharf

Rob,

I notice in the documentation that the sqlite3_progress_handler() method
is marked experimental.  Is that significant?


No idea, that's a question Richard Hipp may answer..

Michael


--
http://MichaelScharf.blogspot.com/



Re: [sqlite] sqlite3_interrupt() and threads

2006-07-25 Thread drh
Michael Scharf [EMAIL PROTECTED] wrote:
 Rob,
  I notice in the documentation that the sqlite3_progress_handler() method
  is marked experimental.  Is that significant?
 
 No idea, that's a question Richard Hipp may answer..
 

I need to remove the experimental marking.  Perhaps
somebody could create a ticket to remind me ;-)

While you are at it, consider creating an enhancement
ticket to allow sqlite3_interrupt to be called from
a different thread.
--
D. Richard Hipp   [EMAIL PROTECTED]



[sqlite] unsubscribe me please RE: [sqlite] sqlite3_interrupt() and threads

2006-07-25 Thread Shi, Chunde CTR DISA PEO-C2C
 
 
Chunde Shi
 
[EMAIL PROTECTED]
703 882 1466
703 882 2325



From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tue 7/25/2006 7:06 PM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] sqlite3_interrupt() and threads



Michael Scharf [EMAIL PROTECTED] wrote: 
 Rob, 
  I notice in the documentation that the sqlite3_progress_handler() method 
  is marked experimental.  Is that significant? 
 
 No idea, that's a question Richard Hipp may answer.. 
 

I need to remove the experimental marking.  Perhaps 
somebody could create a ticket to remind me ;-) 

While you are at it, consider creating an enhancement 
ticket to allow sqlite3_interrupt to be called from 
a different thread. 
-- 
D. Richard Hipp   [EMAIL PROTECTED]