locked
signalR and concurrency in javascript RRS feed

  • Question

  • User-1092841962 posted

    Hi,

    I have a webb application where the webpage shows a table with initially 0 rows.

    The users can create data through an external jquery/javascript library which i then send to a SignalR hub for processing. 

    The data can come in bursts between 1-100 quick events (maybe 2 or 3 per second).

    When the hub has finished processing each packet, it pushes out an object to the webpage which updates the table and adds a new row if that item doesn't exists, or otherwise updates some counters. It can even remove that row if the counter reaches 0.

    Am I right to assume that there can be some concurrency issues in the javascript/jquery function that gets called when the hub has finished processing? If multiple packages get processed at the same time they might get executed by javascript asynchronously and execute a critical section (the table update function) concurrently.

    What would be the best way to solve this issue? Try to implement some kind of Mutex? I'm couldn't find any good examples online. The only thing that I found that might solve the issue was this link:

    http://www.developer.com/lang/jscript/article.php/3592016/AJAX-from-Scratch-Implementing-Mutual-Exclusion-in-JavaScript.htm

    However, the functions that handle critical sections didn't take any parameters so I'm not sure how to apply it (my javascript skills are only intermediate).

    Another approach might be some kind of queue in the hub, but then you would need to know when the client has finished processing the update package somehow...

    Any ideas?

    Thursday, September 14, 2017 7:14 AM

All replies