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
Unknown Object (File)
Mon, Nov 25, 2:57 AM
Unknown Object (File)
Mon, Nov 25, 2:39 AM
Unknown Object (File)
Mon, Nov 25, 2:26 AM
Unknown Object (File)
Mon, Nov 25, 2:24 AM
Unknown Object (File)
Mon, Nov 25, 12:47 AM
Unknown Object (File)
Fri, Nov 22, 11:34 AM
Unknown Object (File)
Mon, Nov 11, 7:04 PM
Unknown Object (File)
Mon, Nov 11, 4:50 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
No Lint Coverage
Unit
No Test Coverage

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