summaryrefslogtreecommitdiff
path: root/include/my_sys.h
diff options
context:
space:
mode:
authorunknown <serg@serg.mysql.com>2002-06-20 00:55:06 +0000
committerunknown <serg@serg.mysql.com>2002-06-20 00:55:06 +0000
commitb043f9233c1b1fa56d99cc3e503a985bd876b687 (patch)
tree43061efc1a2e3133b918b0781d0834c651e539a1 /include/my_sys.h
parentccf18acc242f33fffca016c1e28c99e6e4e443b7 (diff)
parentcf7be403f323a0d38cf23ffa46d5dcdbfeb38a8f (diff)
downloadmariadb-git-b043f9233c1b1fa56d99cc3e503a985bd876b687.tar.gz
resolving
include/my_sys.h: Auto merged myisam/mi_check.c: Auto merged myisam/myisamchk.c: Auto merged mysys/mf_iocache.c: Auto merged include/myisam.h: post-merge myisam/mi_write.c: post-merge
Diffstat (limited to 'include/my_sys.h')
-rw-r--r--include/my_sys.h59
1 files changed, 55 insertions, 4 deletions
diff --git a/include/my_sys.h b/include/my_sys.h
index 894a9c653a7..847e9601bc5 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -36,7 +36,7 @@ extern int NEAR my_errno; /* Last error in mysys */
#include <m_ctype.h> /* for CHARSET_INFO */
#endif
-#include <stdarg.h>
+#include <stdarg.h>
#define MYSYS_PROGRAM_USES_CURSES() { error_handler_hook = my_message_curses; mysys_uses_curses=1; }
#define MYSYS_PROGRAM_DONT_USE_CURSES() { error_handler_hook = my_message_no_curses; mysys_uses_curses=0;}
@@ -284,7 +284,7 @@ extern struct my_file_info
{
my_string name;
enum file_type type;
-#if defined(THREAD) && !defined(HAVE_PREAD)
+#if defined(THREAD) && !defined(HAVE_PREAD)
pthread_mutex_t mutex;
#endif
} my_file_info[MY_NFILE];
@@ -307,6 +307,45 @@ typedef struct st_dynamic_string
struct st_io_cache;
typedef int (*IO_CACHE_CALLBACK)(struct st_io_cache*);
+#ifdef THREAD
+typedef struct st_io_cache_share
+{
+ /* to sync on reads into buffer */
+ pthread_mutex_t mutex;
+ pthread_cond_t cond;
+ int count;
+ /* actual IO_CACHE that filled the buffer */
+ struct st_io_cache *active;
+ /* the following will go implemented whenever the need arises */
+#ifdef NOT_IMPLEMENTED
+ /* whether the structure should be free'd */
+ my_bool alloced;
+#endif
+} IO_CACHE_SHARE;
+
+#define lock_io_cache(info) \
+ ( \
+ (errno=pthread_mutex_lock(&((info)->share->mutex))) ? -1 : ( \
+ (info)->share->count ? ( \
+ --((info)->share->count), \
+ pthread_cond_wait(&((info)->share->cond), \
+ &((info)->share->mutex)), \
+ (++((info)->share->count) ? \
+ pthread_mutex_unlock(&((info)->share->mutex)) : 0)) \
+ : 1 ) \
+ )
+
+#define unlock_io_cache(info) \
+ ( \
+ pthread_cond_broadcast(&((info)->share->cond)), \
+ pthread_mutex_unlock (&((info)->share->mutex)) \
+ )
+/* -- to catch errors
+#else
+#define lock_io_cache(info)
+#define unlock_io_cache(info)
+*/
+#endif
typedef struct st_io_cache /* Used when cacheing files */
{
@@ -347,10 +386,16 @@ typedef struct st_io_cache /* Used when cacheing files */
WRITE_CACHE, and &read_pos and &read_end respectively otherwise
*/
byte **current_pos, **current_end;
-/* The lock is for append buffer used in SEQ_READ_APPEND cache */
#ifdef THREAD
+ /* The lock is for append buffer used in SEQ_READ_APPEND cache
+ need mutex copying from append buffer to read buffer. */
pthread_mutex_t append_buffer_lock;
- /* need mutex copying from append buffer to read buffer */
+ /* The following is used when several threads are reading the
+ same file in parallel. They are synchronized on disk
+ accesses reading the cached part of the file asynchronously.
+ It should be set to NULL to disable the feature. Only
+ READ_CACHE mode is supported. */
+ IO_CACHE_SHARE *share;
#endif
/*
A caller will use my_b_read() macro to read from the cache
@@ -635,6 +680,12 @@ extern my_bool reinit_io_cache(IO_CACHE *info,enum cache_type type,
my_off_t seek_offset,pbool use_async_io,
pbool clear_cache);
extern int _my_b_read(IO_CACHE *info,byte *Buffer,uint Count);
+#ifdef THREAD
+extern int _my_b_read_r(IO_CACHE *info,byte *Buffer,uint Count);
+extern int init_io_cache_share(IO_CACHE *info,
+ IO_CACHE_SHARE *s, uint num_threads);
+extern int remove_io_thread(IO_CACHE *info);
+#endif
extern int _my_b_seq_read(IO_CACHE *info,byte *Buffer,uint Count);
extern int _my_b_net_read(IO_CACHE *info,byte *Buffer,uint Count);
extern int _my_b_get(IO_CACHE *info);