Re: [sqlite] Request for an example code use async IO

2011-04-05 Thread Pavel Ivanov
To avoid races you should do this:

Main thread:
 - sqlite3async_initialize()
 - Starts child thread
 - sqlite3_open_v2()
 - sqlite3_exec(), sqlite3_prepare_v2()/sqlite3_step(), etc
 - sqlite3_close()
 - Halts and joins child thread
 - sqlite3async_shutdown()
 - exits

Child thread:
 - sqlite3async_run()


Pavel


On Tue, Apr 5, 2011 at 1:45 PM, Ricky Huang  wrote:
> On Apr 4, 2011, at 7:10 PM, Pavel Ivanov wrote:
>
>>> Can someone be so kind as to provide a short example of initializing 
>>> asynchronous module, opening DB for read/write, create a table, and write 
>>> some data to it?
>>
>> […] All you need to do is to initialize async module and call 
>> sqlite3async_run in the dedicated thread. […]
>
> Thanks for getting back to me Pavel.
>
> So let me see if I understand what you said:
>
> Main thread:
>  - Starts child thread
>  - sqlite3_open_v2()
>  - sqlite3_exec(), sqlite3_prepare_v2()/sqlite3_step(), etc
>  - sqlite3_close()
>  - Halts and joins child thread
>
> Child thread:
>  - sqlite3async_initialize()
>  - sqlite3async_run()
>  - sqlite3async_shutdown()
>
>
> is that correct?
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Request for an example code use async IO

2011-04-05 Thread Ricky Huang
On Apr 4, 2011, at 7:10 PM, Pavel Ivanov wrote:

>> Can someone be so kind as to provide a short example of initializing 
>> asynchronous module, opening DB for read/write, create a table, and write 
>> some data to it?
> 
> […] All you need to do is to initialize async module and call 
> sqlite3async_run in the dedicated thread. […]

Thanks for getting back to me Pavel.

So let me see if I understand what you said:

Main thread:
  - Starts child thread
  - sqlite3_open_v2()
  - sqlite3_exec(), sqlite3_prepare_v2()/sqlite3_step(), etc
  - sqlite3_close()
  - Halts and joins child thread

Child thread:
  - sqlite3async_initialize()
  - sqlite3async_run()
  - sqlite3async_shutdown()


is that correct?
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Request for an example code use async IO

2011-04-04 Thread Pavel Ivanov
> Can someone be so kind as to provide a short example of initializing 
> asynchronous module, opening DB for read/write, create a table, and write 
> some data to it?

There's nothing special in opening db, creating table or writing data
into it while using async module. You should use the same API in the
same way you use it without async module. All you need to do is to
initialize async module and call sqlite3async_run in the dedicated
thread. I believe everything is well explained in here
http://www.sqlite.org/asyncvfs.html (pay special attention to section
2.0) and in sqlite3async.h header. Do you find something specifically
hard to understand?


Pavel


On Mon, Apr 4, 2011 at 9:47 PM, Ricky Huang  wrote:
> Hi,
>
> I am planning on incorporating the sqlite3async module into my project to 
> improve code responsiveness during disk writes.  I've Googled all over for 
> example code on using the module but can't find any.
>
> Can someone be so kind as to provide a short example of initializing 
> asynchronous module, opening DB for read/write, create a table, and write 
> some data to it?
>
>
> Thanks in advance.
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Request for an example code use async IO

2011-04-04 Thread Ricky Huang
Hi,

I am planning on incorporating the sqlite3async module into my project to 
improve code responsiveness during disk writes.  I've Googled all over for 
example code on using the module but can't find any.

Can someone be so kind as to provide a short example of initializing 
asynchronous module, opening DB for read/write, create a table, and write some 
data to it?


Thanks in advance.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users