Page MenuHomePhabricator

[NativeRustLibrary] support `std::promise`
ClosedPublic

Authored by kamil on Jan 11 2024, 10:04 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Oct 18, 7:40 AM
Unknown Object (File)
Fri, Oct 18, 7:40 AM
Unknown Object (File)
Fri, Oct 18, 7:40 AM
Unknown Object (File)
Fri, Oct 18, 7:39 AM
Unknown Object (File)
Fri, Oct 18, 6:38 AM
Unknown Object (File)
Mon, Oct 7, 10:39 AM
Unknown Object (File)
Mon, Oct 7, 10:33 AM
Unknown Object (File)
Mon, Oct 7, 7:57 AM
Subscribers

Details

Summary

Context in ENG-6384

I tried to implement it using the template (std::promise<T>) but this complicates the code. I think we can assume the caller will handle it properly.

Test Plan
  1. Test both rejecting/resolving
  2. I used one of existing methods and added sleep in Rust code to wait long enough and make sure it works

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kamil held this revision as a draft.
kamil retitled this revision from [NativeRustModule] support `std::promise` to [NativeRustLibrary] support `std::promise`.
kamil published this revision for review.Jan 11 2024, 10:33 AM
varun requested changes to this revision.Jan 12 2024, 11:58 AM

you tested that both promise types work?

native/cpp/CommonCpp/NativeModules/InternalModules/RustPromiseManager.cpp
47–49 ↗(On Diff #35556)

i introduced this code originally but it looks wrong to me now. we probably shouldn't be adding JSI promises to promises if the jsInvoker is missing

This revision now requires changes to proceed.Jan 12 2024, 11:58 AM
native/cpp/CommonCpp/NativeModules/InternalModules/RustPromiseManager.cpp
8 ↗(On Diff #35556)

Can you explain what’s going on with the formatting changes?

native/cpp/CommonCpp/NativeModules/InternalModules/RustPromiseManager.cpp
8 ↗(On Diff #35556)

This is consistent with CommConstants.cpp (which was introduced afterwards, but uses the better style IMO)

native/cpp/CommonCpp/NativeModules/InternalModules/RustPromiseManager.cpp
8 ↗(On Diff #35556)

Shouldn't the style be set by clang-format?

you tested that both promise types work?

yes, in D10631 where we use both, C++ for prekey rotation and JSI to log in to Identity (D10327)

native/cpp/CommonCpp/NativeModules/InternalModules/RustPromiseManager.cpp
8 ↗(On Diff #35556)

I manually ran clang-format so now it is, not sure why previously it wasn't (it should have been formatted last time the file was committed)

47–49 ↗(On Diff #35556)

fixed

This revision is now accepted and ready to land.Jan 15 2024, 12:08 PM
This revision was automatically updated to reflect the committed changes.