You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Henrique Mendonca (JIRA)" <ji...@apache.org> on 2011/03/09 12:54:59 UTC

[jira] Commented: (THRIFT-1087) Nonblocking asynchronous JS services

    [ https://issues.apache.org/jira/browse/THRIFT-1087?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13004493#comment-13004493 ] 

Henrique Mendonca commented on THRIFT-1087:
-------------------------------------------

{quote}
*Performance Note*   When _bAsync_ is set to false, *send* operations are synchronous, and Windows Internet Explorer does not accept input or produce output while *send* operations are in progress. Therefore, this setting should not be used in situations where it is possible for a user to be waiting on the *send* operation to complete.
{quote}
_From MSDN:_ http://msdn.microsoft.com/en-us/library/ms536648%28v=vs.85%29.aspx

The same happens with most of the current browsers

> Nonblocking asynchronous JS services
> ------------------------------------
>
>                 Key: THRIFT-1087
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1087
>             Project: Thrift
>          Issue Type: New Feature
>          Components: JavaScript - Compiler, JavaScript - Library
>    Affects Versions: 0.6
>            Reporter: Henrique Mendonca
>            Assignee: Henrique Mendonca
>              Labels: javascript, thrift
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> The current js lib uses an ajax synchronous request, which is not very typical for javascript. Since the current browsers' js are still single threaded, they block the whole website until we get an answer from the server.
> Current trunk:
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId) \{
>   this.send_getMyObject(objectId)   //send request and wait for response
>   return this.recv_getMyObject()      //interpret response
> }
> {quote}
> I propose something like this: (pseudo-code + extra verbose for better understanding)
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId, onSuccessHandler) \{
>   if ( ! onSucessHandler) \{
>     this.send_getMyObject(objectId)   //send request and wait for response
>     return this.recv_getMyObject()      //interpret response
>   } else \{
>     Thrift.HttpRequest.post( send_getMyObject(objectId) );   //send request asynchronously
>     Thrift.HttpRequest.onreadystatechange = function () \{ onSuccessHandler( this.recv_getMyObject() ); } //call handler on success
>     return Thrift.HttpRequest   //return request object, as user might need to attach an onError handler
>   }
> }
> {quote}
> I think it should be something similar to the jQuery post: http://api.jquery.com/jQuery.post/
> and it will still keep the compatibility with legacy code.
> Any thoughts or ideas?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira