# MapReduce Pool Model ## Building MapReduce Model github : [MapReduce Model](https://github.com/ilkclord/Map_Reduce) ### Schedule * [x] jobqueue * [ ] Main Pool * [ ] Error Handle ### Jobqueue For the jobqueue , I choose ringbuffer as the data structure .There are some advantages and will be introduced below . * **Accuracy** Compared with linked list , the `add` / `remove` option in ring buffer is more easier to maintain . If we can assure the `read` / `write` in a correct position , then there won't arise an Error . * **Fixed Size** Since the ring buffer limits the entry of the elements , we can implement by using an array which only cost us const time for finding the specific data . #### Position When `queue_r` or `queue_w` were called , we reserve a position for them ,and keeps going on . #### Flags To assure the write / read operation isn't interrupt , I use 3 flags to show the states and assure the accuracy . `readable` : the node is ready to be read , can't be written `writing` : the node is hooking right now `raw` : the original state , is ready to be written For the termination of the queue , cause we have a while loop to wait the node ready to be written or read , we use flags to break out the loop `act` : queue is running now `rc` : let the reading process terminate (stop waiting_ `wc` : let the writing process terminate (stop waiting) `rest` : queue isn't running now Note that the sequence of calling `rc` and `wc` matters , if `wc`->`rc` , we expected the data were all read out the queue . If `rc`->`wc` , we expected the data were all written into the queue . ### Main Pool ***upcoming ~***