From d2e1163306b6c78afadf686b6aa233b509bad8ab Mon Sep 17 00:00:00 2001 From: Denver Gingerich Date: Tue, 2 Feb 2021 23:26:13 +0000 Subject: [PATCH] copy sgx-catapult .all Deferable; not factored yet Specifically https://gitlab.com/ossguy/sgx-catapult/commit/583f98b is copied here. While there was another commit in that merge request (at https://gitlab.com/ossguy/sgx-catapult/merge_requests/20), that commit (https://gitlab.com/ossguy/sgx-catapult/commit/8f9e588) was already included in 9d556e1 so we don't need to copy the entire merge request here, only the single commit in that merge request that included the "Allow EMPromise.all to accept both Promise and Deferable" part. Note that this is required in sgx-bwmsgsv2 since jmp-fwdcalls uses it and jmp-fwdcalls must be able to run with either sgx-catapult or sgx-bwmsgsv2. As an example, the following commit and MR require it: https://gitlab.com/ossguy/jmp-fwdcalls/commit/405ef3c and https://gitlab.com/ossguy/jmp-fwdcalls/merge_requests/12 . We are doing the copy here since we haven't properly refactored the common parts of sgx-catapult and sgx-bwmsgsv2 so they can, for example, share one em_promise.rb file. --- em_promise.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/em_promise.rb b/em_promise.rb index 9968885523a65ec36804516030ed4d102c9e5ddb..853594b1e349efc43009fa76b4825ed6bec0fa53 100644 --- a/em_promise.rb +++ b/em_promise.rb @@ -50,6 +50,16 @@ class EMPromise < Promise def self.reject(e) new.tap { |promise| promise.reject(e) } end + + def self.all(enumerable) + super(enumerable.map { |input| + if input.respond_to?(:promise) + input.promise + else + input + end + }) + end end module EventMachine