]> git.donarmstrong.com Git - samtools.git/blobdiff - bgzf.h
works
[samtools.git] / bgzf.h
diff --git a/bgzf.h b/bgzf.h
index 4f69225684c8b1047aa47f1ff99d25118a90ce20..cb67681544b51f96efef226fa7a6232124c43420 100644 (file)
--- a/bgzf.h
+++ b/bgzf.h
@@ -1,7 +1,7 @@
 /* The MIT License
 
    Copyright (c) 2008 Broad Institute / Massachusetts Institute of Technology
-                 2011 Attractive Chaos <attractor@live.co.uk>
+                 2011, 2012 Attractive Chaos <attractor@live.co.uk>
 
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
@@ -31,8 +31,9 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <zlib.h>
+#include <sys/types.h>
 
-#define BGZF_BLOCK_SIZE     0xff00
+#define BGZF_BLOCK_SIZE     0xff00 // make sure compressBound(BGZF_BLOCK_SIZE) < BGZF_MAX_BLOCK_SIZE
 #define BGZF_MAX_BLOCK_SIZE 0x10000
 
 #define BGZF_ERR_ZLIB   1
 #define BGZF_ERR_MISUSE 8
 
 typedef struct {
-       int errcode:30, is_write:2;
-       int compress_level, n_threads;
+       int errcode:16, is_write:2, compress_level:14;
        int cache_size;
     int block_length, block_offset;
     int64_t block_address;
     void *uncompressed_block, *compressed_block;
        void *cache; // a pointer to a hash table
        void *fp; // actual file handler; FILE* on writing; FILE* or knetFile* on reading
+       void *mt; // only used for multi-threading
 } BGZF;
 
 #ifndef KSTRING_T
@@ -190,6 +191,15 @@ extern "C" {
         */
        int bgzf_read_block(BGZF *fp);
 
+       /**
+        * Enable multi-threading (only effective on writing)
+        *
+        * @param fp          BGZF file handler; must be opened for writing
+        * @param n_threads   #threads used for writing
+        * @param n_sub_blks  #blocks processed by each thread; a value 64-256 is recommended
+        */
+       int bgzf_mt(BGZF *fp, int n_threads, int n_sub_blks);
+
 #ifdef __cplusplus
 }
 #endif