Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolving a promise with another already resolved promise does not trigger callbacks/messages #57

Closed
smarr opened this issue Nov 22, 2016 · 0 comments
Assignees
Labels
bug Fixes an issue, incorrect implementation

Comments

@smarr
Copy link
Owner

smarr commented Nov 22, 2016

When resolving a promise with a resolved promise like this:

| pp ppChained |
pp := actors createPromisePair.
ppChained := actors createPromisePair.

(* first resolve *)
pp resolver resolve: 11.
(* then chain *)
ppChained resolver resolve: pp promise.

Then any action scheduled on ppChained promise is not triggered currently.
Full example below.

Note, a solution for this might also think about fixing issue #29.

class Hello usingPlatform: platform = Value (
| private actors = platform actors.
|)(

  public testFirstResolvedThenChained = (
    | pp ppChained ppCompletion callbackPG |
    pp := actors createPromisePair.
    ppChained := actors createPromisePair.
    ppCompletion := actors createPromisePair.

    (* first resolve *)
    pp resolver resolve: 11.
    (* then chain *)
    ppChained resolver resolve: pp promise.

    callbackPG := pp promise whenResolved: [:v |
      '[testFirstResolvedThenChained] whenResolved on pp: ' print.
      'v was resolved to ' print.
      v print.
      '. Expected: 11' println.
    ].

    callbackPG := callbackPG, (ppChained promise whenResolved: [:v |
      '[testFirstResolvedThenChained] whenResolved on ppChained: ' print.
      'v was resolved to ' print.
      v print.
      '. Expected: 11' println.
    ]).

    callbackPG whenResolved: [:v |
      ppCompletion resolver resolve: #done.
    ].

    ^ ppCompletion promise.
  )

  public testFirstChainedThenResolved = (
    | pp ppChained ppCompletion callbackPG |
    pp := actors createPromisePair.
    ppChained := actors createPromisePair.
    ppCompletion := actors createPromisePair.

    (* first chain *)
    ppChained resolver resolve: pp promise.
    
    (* then resolve *)
    pp resolver resolve: 11.

    callbackPG := pp promise whenResolved: [:v |
      '[testFirstChainedThenResolved] whenResolved on pp: ' print.
      'v was resolved to ' print.
      v print.
      '. Expected: 11' println.
    ].

    callbackPG := callbackPG, (ppChained promise whenResolved: [:v |
      '[testFirstChainedThenResolved] whenResolved on ppChained: ' print.
      'v was resolved to ' print.
      v print.
      '. Expected: 11' println.
    ]).

    callbackPG whenResolved: [:v |
      ppCompletion resolver resolve: #done.
    ].

    ^ ppCompletion promise.
  )

  public main: args = (
    | pp |
    pp := actors createPromisePair.

    testFirstChainedThenResolved whenResolved: [:v |
      testFirstResolvedThenChained whenResolved: [:vv |
        pp resolver resolve: 0 ] 
    ].
    
    ^ pp promise
  )
)
@smarr smarr added the bug Fixes an issue, incorrect implementation label Nov 22, 2016
@smarr smarr self-assigned this Nov 22, 2016
ctrlpz added a commit to MetaConc/SOMns that referenced this issue Nov 22, 2016
- TODO: for the sender (resolver) side implement stepping strategy in Truffle to get the location of the end of the message executed
- TODO: for the receiver side (resolution) resolved issue smarr#57
ctrlpz added a commit to MetaConc/SOMns that referenced this issue Nov 22, 2016
- TODO: for the sender (resolver) side implement stepping strategy in Truffle to get the location of the end of the message executed
- TODO: for the receiver side (resolution) resolved issue smarr#57
ctrlpz added a commit to MetaConc/SOMns that referenced this issue Nov 24, 2016
- TODO: for the sender (resolver) side implement stepping strategy in Truffle to get the location of the end of the message executed
- TODO: for the receiver side (resolution) resolved issue smarr#57
smarr added a commit that referenced this issue Nov 24, 2016
Tests for issue #57.

Signed-off-by: Stefan Marr <git@stefan-marr.de>
smarr added a commit that referenced this issue Nov 24, 2016
TODO: handle issues that are resolved with error
Signed-off-by: Stefan Marr <git@stefan-marr.de>
@smarr smarr closed this as completed in #63 Nov 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes an issue, incorrect implementation
Projects
None yet
Development

No branches or pull requests

1 participant