aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2014-04-24 12:28:28 +0000
committerdrh <drh@noemail.net>2014-04-24 12:28:28 +0000
commit3de4df27dda707357d3fc62bf1c318a7a2e9dfeb (patch)
tree3dbe13908d622289b29f2468711862288994d7b2 /src
parent9e0ed8d4ecf02a978f6ec0e8011a3adc5004d0e4 (diff)
downloadsqlite-3de4df27dda707357d3fc62bf1c318a7a2e9dfeb.tar.gz
sqlite-3de4df27dda707357d3fc62bf1c318a7a2e9dfeb.zip
Improvements to comments. Store some extra information in SqliteThread that
is useful for debugging. FossilOrigin-Name: 9fb5e212089d85cdd3b4787dd69c72e6d84560b6
Diffstat (limited to 'src')
-rw-r--r--src/threads.c10
-rw-r--r--src/vdbesort.c17
2 files changed, 17 insertions, 10 deletions
diff --git a/src/threads.c b/src/threads.c
index eeab5379c..64975801b 100644
--- a/src/threads.c
+++ b/src/threads.c
@@ -37,9 +37,11 @@
/* A running thread */
struct SQLiteThread {
- pthread_t tid;
- int done;
- void *pOut;
+ pthread_t tid; /* Thread ID */
+ int done; /* Set to true when thread finishes */
+ void *pOut; /* Result returned by the thread */
+ void *(*xTask)(void*); /* The thread routine */
+ void *pIn; /* Argument to the thread */
};
/* Create a new thread */
@@ -56,6 +58,8 @@ int sqlite3ThreadCreate(
p = sqlite3Malloc(sizeof(*p));
if( p==0 ) return SQLITE_NOMEM;
memset(p, 0, sizeof(*p));
+ p->xTask = xTask;
+ p->pIn = pIn;
if( sqlite3GlobalConfig.bCoreMutex==0
|| pthread_create(&p->tid, 0, xTask, pIn)!=0
){
diff --git a/src/vdbesort.c b/src/vdbesort.c
index 6fc4e4e10..46de73528 100644
--- a/src/vdbesort.c
+++ b/src/vdbesort.c
@@ -15,7 +15,7 @@
** using indexes and without LIMIT clauses.
**
** The VdbeSorter object implements a multi-threaded external merge sort
-** algorithm that is efficient even if the number of element being sorted
+** algorithm that is efficient even if the number of elements being sorted
** exceeds the available memory.
**
** Here is the (internal, non-API) interface between this module and the
@@ -104,9 +104,7 @@
**
** When Rewind() is called, any data remaining in memory is flushed to a
** final PMA. So at this point the data is stored in some number of sorted
-** PMAs within temporary files on disk. Within a single file sorter is
-** running in single threaded mode, or distributed between one or more files
-** for multi-threaded sorters.
+** PMAs within temporary files on disk.
**
** If there are fewer than SORTER_MAX_MERGE_COUNT PMAs in total and the
** sorter is running in single-threaded mode, then these PMAs are merged
@@ -158,7 +156,7 @@ typedef struct SorterRecord SorterRecord; /* A record being sorted */
typedef struct SortSubtask SortSubtask; /* A sub-task in the sort process */
typedef struct SorterFile SorterFile; /* Temporary file object wrapper */
typedef struct SorterList SorterList; /* In-memory list of records */
-typedef struct IncrMerger IncrMerger;
+typedef struct IncrMerger IncrMerger; /* Read & merge multiple PMAs */
/*
** A container for a temp file handle and the current amount of data
@@ -170,11 +168,16 @@ struct SorterFile {
};
/*
-** In memory linked list of records.
+** An in-memory list of objects to be sorted.
+**
+** If aMemory==0 then each object is allocated separately and the objects
+** are connected using SorterRecord.u.pNext. If aMemory!=0 then all objects
+** are stored in the aMemory[] bulk memory, one right after the other, and
+** are connected using SorterRecord.u.iNext.
*/
struct SorterList {
SorterRecord *pList; /* Linked list of records */
- u8 *aMemory; /* If non-NULL, blob of memory for pList */
+ u8 *aMemory; /* If non-NULL, bulk memory to hold pList */
int szPMA; /* Size of pList as PMA in bytes */
};