-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace SharedBuffer::Semaphore with Core::SharedSemaphore #1737
Conversation
I think we also need to "move" the shared over process boundary feature into the Binary semaphore than.. Now I do not think that the semaphore (at least on windows), can be shared over process boundaries. That was the name shared between the two processes. I think this feature is now lost and the SharedBuffer no longer works on WIndows... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Questions and discussions added :-) Maybe a confcall/skype chat in TPX ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yee we saved potentially 4 bytes on a 32 bit platform! Looks very good now!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(also please mind the whitespaces)
Source/core/SharedBuffer.cpp
Outdated
#else | ||
, _producer(reinterpret_cast<uint8_t*>(_administration) + sizeof(Administration)) | ||
, _consumer(reinterpret_cast<uint8_t*>(_administration) + sizeof(Administration) + SharedSemaphore::Size()) | ||
#endif | ||
, _customerAdministration(PointerAlign(&(reinterpret_cast<uint8_t*>(_administration)[sizeof(Administration)]))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
customerAdministration needs to be adjusted, now it overwrites the semaphore structures
Source/core/Sync.cpp
Outdated
} | ||
|
||
bool | ||
SharedSemaphore::IsLocked() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's better to change this to Count() and return the current semaphore lock value? IsLocked() limits this to a binary semaphore interface again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do agree here with @sebaszm but see it is not adapted, so I guess this is the last bit we need to change. I assume that if Cunt() const -> 0 it IsLocked() const -> true
Source/core/Sync.h
Outdated
public: | ||
uint32_t Lock(const uint32_t waitTime); | ||
uint32_t Unlock(); | ||
bool IsLocked(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the method should be uint32_t Count() const;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor things, we're almost there!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM :-)
In SharedBuffer, a class "Semaphore" was being used. This used <semaphore.h>, and the problem was due to sem_clockwait not available on the apple platform and not in the musl library.
In Sync.h, a class "BinarySemaphore" (previously "BinairySemaphore") was defined, which instead uses <pthread.h>, using mutex and condition variables instead.
Other differences include constructor values as SharedBuffer::Semaphore would take either TCHAR or a sem_t* depending on platform, whilst Core::BinarySemaphore takes in a bool flag.
Essentially, they try to do the same thing, as both act as a binary semaphore