Author: harsha <hhs.couchbase@gmail.com>
Date:   Fri Sep 5 17:15:05 2014 +0530

    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.

Author: Sarath Lakshman <sarathlakshman@slynux.com>
Date:   Fri Sep 12 12:27:11 2014 +0530

    Use round-robin scheduling for mapreduce nif workers

    Using random work allocation to mapreduce nif worker threads may
    cause contention on worker threads and work distribution may not be
    uniform. Considering the workload, when a map context is created
    the updater uses that context to perform a number of map operations
    during the lifetime of the updater. Hence, the best work distribution
    may be to assign one worker thread to a map context and use the
    same worker for all map tasks for that context. The worker thread
    can be assigned in round-robin fashion to each map context created
    by the updater.

Author: harsha <hhs.couchbase@gmail.com>
Date:   Sat Sep 20 02:56:06 2014 +0530

    Replace enif mutex and condition variables with stl counterparts.

    Mutex and Condition variables which are part of enif suite seems to
    be loosing signals on condition variable and thus puts both consumer
    and producer into sleep simultaneously resulting in deadlock.
    These mutex and condition variables are replaced by C++ stl counterparts.
    Also since we do map_doc serially for one document after another there
    is no much gain if we increase queue size, so setting it to 2 now.
    Benchmarking with unit tests also confirm this. Later if we do parallel
    map_docs we can set the queue size optimally.