MB-11917 Async map_doc implementation

map_doc function make use of NIF which in turn calls v8 library
to perform map function. Currently this is implemented in
synchronous fashion. Since map may take long amount of time
depending on map function, number of views and number of documents,
it is better to implement it in asynchronous fashion. In order to
implement async map, a template task queue class is implemented and
all map requests are enqueued and the function returns immediately.
4 global threads are created since view engine support 4 concurrent
view indexing. All incoming map requests are randomly assigned to
one of these 4 threads to balance load. These worker threads
dequeue tasks, does the map and sends map results or error as
messages to erlang world. This will help erlang scheduler to get
proper reduction counts for map request and thus perform fair
task scheduling.

Change-Id: I8e53a85fe4056df480e0f74c0cf94c0410ea56c9
Revert "MB-11917 Async map_doc implementation"

This reverts commit 20d47e855415af5027f47f3c724f311facfd624d.
MB-11917 Async map_doc implementation

map_doc function make use of NIF which in turn calls v8 library
to perform map function. Currently this is implemented in
synchronous fashion. Since map may take long amount of time
depending on map function, number of views and number of documents,
it is better to implement it in asynchronous fashion. In order to
implement async map, a template task queue class is implemented and
all map requests are enqueued and the function returns immediately.
4 global threads are created since view engine support 4 concurrent
view indexing. All incoming map requests are randomly assigned to
one of these 4 threads to balance load. These worker threads
dequeue tasks, does the map and sends map results or error as
messages to erlang world. This will help erlang scheduler to get
proper reduction counts for map request and thus perform fair
task scheduling.

Change-Id: I8e53a85fe4056df480e0f74c0cf94c0410ea56c9
MB-11917 Async map_doc implementation

map_doc function make use of NIF which in turn calls v8 library
to perform map function. Currently this is implemented in
synchronous fashion. Since map may take long amount of time
depending on map function, number of views and number of documents,
it is better to implement it in asynchronous fashion. In order to
implement async map, a template task queue class is implemented and
all map requests are enqueued and the function returns immediately.
4 global threads are created since view engine support 4 concurrent
view indexing. All incoming map requests are randomly assigned to
one of these 4 threads to balance load. These worker threads
dequeue tasks, does the map and sends map results or error as
messages to erlang world. This will help erlang scheduler to get
proper reduction counts for map request and thus perform fair
task scheduling.

Change-Id: Iea33c88cea7060cef84b0398a0de1c79e1775cff
Merge branch 'master' of github.com:hsharsha/couchdb

Conflicts:
	src/mapreduce/mapreduce.erl
	src/mapreduce/mapreduce.h
	src/mapreduce/mapreduce_nif.cc
	src/mapreduce/taskqueue.h

Change-Id: I359be4299788c98574c193b4308864f6f0d10345