Skip to content
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

Added CSync class as high level CV wrapper #1067

Merged
merged 8 commits into from
Jan 21, 2020

Conversation

ethouris
Copy link
Collaborator

@ethouris ethouris commented Jan 17, 2020

  1. Added CSync class. This is predicted to be used exclusively in the local context. It should wrap a conditional variable and the associated mutex in order to perform an operation on them together.

  2. The use of CSync class replaces every case of using pthread_cond_* functions directly (small exception is in the timer code).

maxsharabayko and others added 5 commits January 17, 2020 09:35
and m_PassCond to m_BufferLock and m_BufferCond
The only place affected is the garbage collector thread. On Linux it
used to wait for 10 us, on Windows - 1 millisecond. Now 1 millisecond on
both platforms.
@ethouris ethouris added this to the v1.5.0 milestone Jan 17, 2020
@ethouris ethouris added [core] Area: Changes in SRT library core Impact: Low Priority: High Type: Maintenance Work required to maintain or clean up the code labels Jan 17, 2020
srtcore/sync.h Outdated Show resolved Hide resolved
srtcore/sync.cpp Outdated
Comment on lines 167 to 168
// We expect m_nolock == true.
lock_signal(*m_cond, *m_mutex);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m_nolock is something that will be added in the future? Or in the debug logic?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. The comment remained after I purged this from the thread logging implementation stuff.

Copy link
Collaborator

@rndi rndi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a good reason CSync class is not wrapping pthread_cond_init() as well? I think that would help with the move to monotonic clock functions.

@ethouris
Copy link
Collaborator Author

No. This is not its purpose. The purpose of this class is to serve as a local variable wrapping "temporarily" a condition variable and mutex, usually through CGuard (UniqueLock in future). Max will provide another class, together with new thread libraries (#800) that will allow to combine mutex and cv, this time usable as a field that replace separate fields of mutex and cv. However, this solution will not be applicable in every place - only where the use of mutex+cv is simple. This will also replace the use of current CSync::lock_signal provided here in these simple cases.

@rndi rndi merged commit 47b2553 into Haivision:master Jan 21, 2020
@maxsharabayko maxsharabayko mentioned this pull request Jan 29, 2020
18 tasks
@maxsharabayko maxsharabayko mentioned this pull request Mar 18, 2020
13 tasks
@mbakholdina mbakholdina modified the milestones: v1.5.0, v1.4.2 Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[core] Area: Changes in SRT library core Priority: High Type: Maintenance Work required to maintain or clean up the code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants