Page MenuHomePhabricator

Define interface for inter process non-blocking binary lock based on POSIX semaphore
ClosedPublic

Authored by marcin on Jun 28 2022, 8:30 AM.
Tags
None
Referenced Files
F3541915: D4380.id14475.diff
Thu, Dec 26, 7:28 AM
F3541913: D4380.id14461.diff
Thu, Dec 26, 7:28 AM
F3541912: D4380.id14159.diff
Thu, Dec 26, 7:27 AM
F3541911: D4380.id14061.diff
Thu, Dec 26, 7:27 AM
F3541910: D4380.id13904.diff
Thu, Dec 26, 7:27 AM
F3541909: D4380.id.diff
Thu, Dec 26, 7:27 AM
Unknown Object (File)
Tue, Dec 17, 7:58 AM
Unknown Object (File)
Tue, Dec 17, 3:46 AM

Details

Summary

Defines interface for object that encapsulates POSIX try_wait semaphore functionality that can be used to synchronize processes in a non-blocking manner

Test Plan

No test plan. Future diffs will use it.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Looks ok, but I don't know obj-c that well. Is there a good reason behind avoiding C++ syntax in this case?

This revision is now accepted and ready to land.Jun 29 2022, 5:58 AM
native/ios/Comm/TemporalMessageStorage/NonBlockingLock.h
7–8 ↗(On Diff #13904)

We should make sure we're being thoughtful about the annotations here. Typically I see a strong or something, but I guess it might be implied?

native/ios/Comm/TemporalMessageStorage/NonBlockingLock.h
7–8 ↗(On Diff #13904)

According to docs: https://academy.realm.io/posts/tmi-objective-c-property-attributes/ strong is given by default if not specified.

In D4380#124258, @palys-swm wrote:

Looks ok, but I don't know obj-c that well. Is there a good reason behind avoiding C++ syntax in this case?

Actually there are not contraindications to implement this functionality in C++. I decided to go with Objective C since we implement this functionality exclusively to solve ios-specific problem. Most code in our project that is ios-specific is written in Objective C, so I followed this pattern. If we ever wish to use this functionality on Android then it is obligatory to implement it in C++ and place somewhere in CommonCpp. However, I don't know whether POSIX semaphores work on Android.

In D4380#124849, @marcinwasowicz wrote:
In D4380#124258, @palys-swm wrote:

Looks ok, but I don't know obj-c that well. Is there a good reason behind avoiding C++ syntax in this case?

Actually there are not contraindications to implement this functionality in C++. I decided to go with Objective C since we implement this functionality exclusively to solve ios-specific problem. Most code in our project that is ios-specific is written in Objective C, so I followed this pattern. If we ever wish to use this functionality on Android then it is obligatory to implement it in C++ and place somewhere in CommonCpp. However, I don't know whether POSIX semaphores work on Android.

After quick search https://joekuan.wordpress.com/2017/06/03/using-semaphores-on-android/

If you plan to use semaphores on Android, then don’t. This is because the sem_open, sem_close and sem_unlink are not implemented.

I suggested implementing this in C++ because it is better understood by the team, so the maintainability would be improved. The reusability would be a plus, but it can't be achieved in this case.

So let's keep the Obj-C implementation - I was just curious about the reason here.

Introduce files to project.pbxproj.

Rename Temporal to Temporary