diff options
Diffstat (limited to 'js/src/Ice/AsyncResult.js')
-rw-r--r-- | js/src/Ice/AsyncResult.js | 145 |
1 files changed, 71 insertions, 74 deletions
diff --git a/js/src/Ice/AsyncResult.js b/js/src/Ice/AsyncResult.js index 672421ba824..60c5c79a0c1 100644 --- a/js/src/Ice/AsyncResult.js +++ b/js/src/Ice/AsyncResult.js @@ -7,69 +7,64 @@ // // ********************************************************************** -var Ice = require("../Ice/ModuleRegistry").Ice; -Ice.__M.require(module, +const Ice = require("../Ice/ModuleRegistry").Ice; +Ice._ModuleRegistry.require(module, [ - "../Ice/Class", "../Ice/AsyncResultBase", "../Ice/Debug", - "../Ice/Promise", "../Ice/Protocol", "../Ice/Exception", - "../Ice/BasicStream" + "../Ice/Stream" ]); -var AsyncResultBase = Ice.AsyncResultBase; -var Debug = Ice.Debug; -var Promise = Ice.Promise; -var Protocol = Ice.Protocol; -var UserException = Ice.UserException; -var BasicStream = Ice.BasicStream; - -var AsyncResult = Ice.Class(AsyncResultBase, { - __init__: function(com, op, connection, proxy, adapter, completedFn) - { - // - // AsyncResult can be constructed by a sub-type's prototype, in which case the - // arguments are undefined. - // - AsyncResultBase.call(this, com, op, connection, proxy, adapter); - if(com === undefined) - { - return; - } +const AsyncResultBase = Ice.AsyncResultBase; +const Debug = Ice.Debug; +const Protocol = Ice.Protocol; +const UserException = Ice.UserException; +const OutputStream = Ice.OutputStream; +class AsyncResult extends AsyncResultBase +{ + constructor(com, op, connection, proxy, adapter, completedFn) + { + super(com, op, connection, proxy, adapter); this._completed = completedFn; this._is = null; - this._os = com !== null ? new BasicStream(this._instance, Protocol.currentProtocolEncoding) : null; + this._os = com !== null ? new OutputStream(this._instance, Protocol.currentProtocolEncoding) : null; this._state = 0; this._exception = null; this._sentSynchronously = false; - }, - cancel: function() + } + + cancel() { - this.__cancel(new Ice.InvocationCanceledException()); - }, - isCompleted: function() + this.cancelWithException(new Ice.InvocationCanceledException()); + } + + isCompleted() { return (this._state & AsyncResult.Done) > 0; - }, - isSent: function() + } + + isSent() { return (this._state & AsyncResult.Sent) > 0; - }, - throwLocalException: function() + } + + throwLocalException() { if(this._exception !== null) { throw this._exception; } - }, - sentSynchronously: function() + } + + sentSynchronously() { return this._sentSynchronously; - }, - __markSent: function(done) + } + + markSent(done) { Debug.assert((this._state & AsyncResult.Done) === 0); this._state |= AsyncResult.Sent; @@ -77,10 +72,11 @@ var AsyncResult = Ice.Class(AsyncResultBase, { { this._state |= AsyncResult.Done | AsyncResult.OK; this._cancellationHandler = null; - this.succeed(this); + this.resolve(); } - }, - __markFinished: function(ok, completed) + } + + markFinished(ok, completed) { Debug.assert((this._state & AsyncResult.Done) === 0); this._state |= AsyncResult.Done; @@ -95,26 +91,29 @@ var AsyncResult = Ice.Class(AsyncResultBase, { } else { - this.succeed(this); + this.resolve(); } - }, - __markFinishedEx: function(ex) + } + + markFinishedEx(ex) { Debug.assert((this._state & AsyncResult.Done) === 0); this._exception = ex; this._state |= AsyncResult.Done; this._cancellationHandler = null; - this.fail(ex, this); - }, - __cancel: function(ex) + this.reject(ex); + } + + cancelWithException(ex) { this._cancellationException = ex; if(this._cancellationHandler) { this._cancellationHandler.asyncRequestCanceled(this, ex); } - }, - __cancelable: function(handler) + } + + cancelable(handler) { if(this._cancellationException) { @@ -128,53 +127,51 @@ var AsyncResult = Ice.Class(AsyncResultBase, { } } this._cancellationHandler = handler; - }, - __os: function() + } + + getOs() { return this._os; - }, - __is: function() - { - return this._is; - }, - __startReadParams: function() + } + + startReadParams() { - this._is.startReadEncaps(); + this._is.startEncapsulation(); return this._is; - }, - __endReadParams: function() - { - this._is.endReadEncaps(); - }, - __readEmptyParams: function() + } + + endReadParams() { - this._is.skipEmptyEncaps(); - }, - __readParamEncaps: function() + this._is.endEncapsulation(); + } + + readEmptyParams() { - return this._is.readEncaps(null); - }, - __throwUserException: function() + this._is.skipEmptyEncapsulation(); + } + + throwUserException() { Debug.assert((this._state & AsyncResult.Done) !== 0); if((this._state & AsyncResult.OK) === 0) { try { - this._is.startReadEncaps(); + this._is.startEncapsulation(); this._is.throwException(); } catch(ex) { if(ex instanceof UserException) { - this._is.endReadEncaps(); + this._is.endEncapsulation(); } throw ex; } } - }, -}); + } + +} AsyncResult.OK = 0x1; AsyncResult.Done = 0x2; |