| OLD | NEW |
| 1 /* | 1 /* |
| 2 ** 2005 December 14 | 2 ** 2005 December 14 |
| 3 ** | 3 ** |
| 4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
| 5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
| 6 ** | 6 ** |
| 7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
| 8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
| 9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
| 10 ** | 10 ** |
| 11 ************************************************************************* | 11 ************************************************************************* |
| 12 ** | 12 ** |
| 13 ** $Id: test_async.c,v 1.62 2009/04/28 13:01:09 drh Exp $ | |
| 14 ** | |
| 15 ** This file contains a binding of the asynchronous IO extension interface | 13 ** This file contains a binding of the asynchronous IO extension interface |
| 16 ** (defined in ext/async/sqlite3async.h) to Tcl. | 14 ** (defined in ext/async/sqlite3async.h) to Tcl. |
| 17 */ | 15 */ |
| 18 | 16 |
| 19 #define TCL_THREADS | 17 #define TCL_THREADS |
| 20 #include <tcl.h> | 18 #include <tcl.h> |
| 21 | 19 |
| 22 #ifdef SQLITE_ENABLE_ASYNCIO | 20 #ifdef SQLITE_ENABLE_ASYNCIO |
| 23 | 21 |
| 24 #include "sqlite3async.h" | 22 #include "sqlite3async.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 ){ | 77 ){ |
| 80 sqlite3async_shutdown(); | 78 sqlite3async_shutdown(); |
| 81 return TCL_OK; | 79 return TCL_OK; |
| 82 } | 80 } |
| 83 | 81 |
| 84 static Tcl_ThreadCreateType tclWriterThread(ClientData pIsStarted){ | 82 static Tcl_ThreadCreateType tclWriterThread(ClientData pIsStarted){ |
| 85 Tcl_MutexLock(&testasync_g_writerMutex); | 83 Tcl_MutexLock(&testasync_g_writerMutex); |
| 86 *((int *)pIsStarted) = 1; | 84 *((int *)pIsStarted) = 1; |
| 87 sqlite3async_run(); | 85 sqlite3async_run(); |
| 88 Tcl_MutexUnlock(&testasync_g_writerMutex); | 86 Tcl_MutexUnlock(&testasync_g_writerMutex); |
| 87 Tcl_ExitThread(0); |
| 89 TCL_THREAD_CREATE_RETURN; | 88 TCL_THREAD_CREATE_RETURN; |
| 90 } | 89 } |
| 91 | 90 |
| 92 /* | 91 /* |
| 93 ** sqlite3async_start | 92 ** sqlite3async_start |
| 94 ** | 93 ** |
| 95 ** Start a new writer thread. | 94 ** Start a new writer thread. |
| 96 */ | 95 */ |
| 97 static int testAsyncStart( | 96 static int testAsyncStart( |
| 98 void * clientData, | 97 void * clientData, |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 } | 222 } |
| 224 | 223 |
| 225 #endif /* SQLITE_ENABLE_ASYNCIO */ | 224 #endif /* SQLITE_ENABLE_ASYNCIO */ |
| 226 | 225 |
| 227 /* | 226 /* |
| 228 ** This routine registers the custom TCL commands defined in this | 227 ** This routine registers the custom TCL commands defined in this |
| 229 ** module. This should be the only procedure visible from outside | 228 ** module. This should be the only procedure visible from outside |
| 230 ** of this module. | 229 ** of this module. |
| 231 */ | 230 */ |
| 232 int Sqlitetestasync_Init(Tcl_Interp *interp){ | 231 int Sqlitetestasync_Init(Tcl_Interp *interp){ |
| 233 #if SQLITE_ENABLE_ASYNCIO | 232 #ifdef SQLITE_ENABLE_ASYNCIO |
| 234 Tcl_CreateObjCommand(interp,"sqlite3async_start",testAsyncStart,0,0); | 233 Tcl_CreateObjCommand(interp,"sqlite3async_start",testAsyncStart,0,0); |
| 235 Tcl_CreateObjCommand(interp,"sqlite3async_wait",testAsyncWait,0,0); | 234 Tcl_CreateObjCommand(interp,"sqlite3async_wait",testAsyncWait,0,0); |
| 236 | 235 |
| 237 Tcl_CreateObjCommand(interp,"sqlite3async_control",testAsyncControl,0,0); | 236 Tcl_CreateObjCommand(interp,"sqlite3async_control",testAsyncControl,0,0); |
| 238 Tcl_CreateObjCommand(interp,"sqlite3async_initialize",testAsyncInit,0,0); | 237 Tcl_CreateObjCommand(interp,"sqlite3async_initialize",testAsyncInit,0,0); |
| 239 Tcl_CreateObjCommand(interp,"sqlite3async_shutdown",testAsyncShutdown,0,0); | 238 Tcl_CreateObjCommand(interp,"sqlite3async_shutdown",testAsyncShutdown,0,0); |
| 240 #endif /* SQLITE_ENABLE_ASYNCIO */ | 239 #endif /* SQLITE_ENABLE_ASYNCIO */ |
| 241 return TCL_OK; | 240 return TCL_OK; |
| 242 } | 241 } |
| OLD | NEW |