Concurrent, Parallel, Distributed

WebSQL Server is designed to leverage the increasingly available parallelism. In essence, parallel computing is composed of tasks executed in parallel, where a task is a unit of computation. Programmers need the ability to define, start/stop, and coordinate parallel tasks. JavaScript is suitable for parallel computing despite its single-threaded computing model. WebSQL Server integrates JavaScript with Generic Parallel Computing (GPC) API and enables JavaScript for parallel computing.

The following distinction is made between the concurrent/asynchronous and parallel JavaScript:

Example:

(function() {
    var exclusive = mutex();

    var param1 = request.query("param1");
    fork("/QueryDatabase.js", param1, exclusive, response);

    var param2 = request.query("param2");
    fork("/QueryDatabase.js", param2, exclusive, response);

    var param3 = request.query("param3");
    fork("/QueryDatabase.js", param3, exclusive, response);
}());
        
QueryDatabase.js
(function() {
    db("select * from aTable where Something = '" + $args[0] + "'", function(data) {
        try {
            var json = "{\"Items\":[0";
            data.forEach(function(item) {
                json += ",";
                json += item.Somevalue;
            });
            json += "]}";
            var exclusive = $args[1];
            join(exclusive, function(state) {
                response.write(json);
                if( state.counter == 3 ) {
                    response.end();
                }
            });
        } catch (err) {
            var exclusive = $args[1];
            join(exclusive, function(state) {
                response.write(err);
                if( state.counter == 3 ) {
                    response.end();
                }
            });
        }
    });
}());
        

Debugging

The Web-based IDE gives the ability to traverse the execution flow of parallel tasks:

The following metrics are provided:

See Also:

Reduction/MapReduce

JavaScript API Reference

Table of Contents