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
F5939935: D4380.id13904.diff
Fri, Apr 18, 7:37 AM
F5931113: D4380.id14061.diff
Fri, Apr 18, 4:11 AM
F5931039: D4380.id14475.diff
Fri, Apr 18, 4:10 AM
F5930931: D4380.id14267.diff
Fri, Apr 18, 4:09 AM
F5928470: D4380.id14461.diff
Fri, Apr 18, 1:59 AM
F5897343: D4380.diff
Thu, Apr 17, 11:23 AM
Unknown Object (File)
Sun, Apr 13, 11:44 AM
Unknown Object (File)
Tue, Apr 8, 6:12 PM

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