Skip to content
This repository was archived by the owner on Nov 13, 2026. It is now read-only.

Complete the timed wait for event - #1000

Merged
janvorli merged 1 commit into
dotnet:masterfrom
janvorli:complete-timed-wait-for-event
Mar 12, 2016
Merged

janvorli merged 1 commit into
dotnet:masterfrom
janvorli:complete-timed-wait-for-event

Conversation

@janvorli

@janvorli janvorli commented Mar 9, 2016

Copy link
Copy Markdown
Member

The timed waiting implementation was not finished for OSX, where
we need to use relative time wait for the cond variable to achieve
reliability even when user fiddles with the system time. Also,
autoreset events were not implemented at all.
There was also an arithmetic overflow issue in the TimeSpecAdd.

This change fixes all of these and also ifdefs out the
RhCompatibleReentrantWaitAny for Unix.

@janvorli

janvorli commented Mar 9, 2016

Copy link
Copy Markdown
Member Author

This change replaces the PR that I have submitted about a week ago, but then closed as @jkotas pointed out that we don't really need waiting for multiple objects in the CoreRT PAL.

@janvorli

Copy link
Copy Markdown
Member Author

@gkhanna79 can you take a look please?

@janvorli

Copy link
Copy Markdown
Member Author

@dotnet-bot test OSX Debug please

@janvorli
janvorli force-pushed the complete-timed-wait-for-event branch from 98547c6 to 6a6fad0 Compare March 11, 2016 15:36
@janvorli

Copy link
Copy Markdown
Member Author

@jkotas can you take a look please?

@jkotas

jkotas commented Mar 11, 2016

Copy link
Copy Markdown
Member

@dotnet-bot test this please

@jkotas

jkotas commented Mar 11, 2016

Copy link
Copy Markdown
Member

LGTM

{
int st = pthread_mutex_init(&m_mutex, NULL);
ASSERT(st == NULL);
FATAL_ASSERT(st == 0, "Failed to initialize UnixEvent mutex");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It may be nice to do a proper error handling for the initialization instead of error handling via FATAL_ASSERTs.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I have used the fail fast, since failure to create the event is non-recoverable. Or can you see a case where we could recover from the failure?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Right, all events seem to be created during runtime startup today, and so handling the failures using fail fast is not too bad. If we have propagated the failure up, the net result is going to be about the same today.

My point was more from the PAL contract point of view. The create event PAL API can return errors, so why not just return error.

@janvorli
janvorli force-pushed the complete-timed-wait-for-event branch from 6a6fad0 to 8a57293 Compare March 12, 2016 00:25
@janvorli

Copy link
Copy Markdown
Member Author

@jkotas I've made the change to return INVALID_HANDLE_VALUE when event initialization fails. I've also made similar change to the destruction and updated the CloseHandle.


class UnixEvent
{
bool m_isValid;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit - it would be better (less padding) for the bool to be together with other bools.

@jkotas

jkotas commented Mar 12, 2016

Copy link
Copy Markdown
Member

LGTM

@janvorli
janvorli force-pushed the complete-timed-wait-for-event branch from 8a57293 to 9c88d1c Compare March 12, 2016 00:41
The timed waiting implementation was not finished for OSX, where
we need to use relative time wait for the cond variable to achieve
reliability even when used fiddles with the system time. Also,
autoreset events were not implemented at all.
There was also an arithmetic overflow issue in the TimeSpecAdd.

This change fixes all of these and also ifdefs out the
RhCompatibleReentrantWaitAny for Unix.
@janvorli
janvorli force-pushed the complete-timed-wait-for-event branch from 9c88d1c to 53faa31 Compare March 12, 2016 00:57
@janvorli

Copy link
Copy Markdown
Member Author

@dotnet-bot test OSX Release please

@janvorli

Copy link
Copy Markdown
Member Author

@dotnet-bot test OSX Debug please

janvorli added a commit that referenced this pull request Mar 12, 2016
@janvorli
janvorli merged commit 905ca44 into dotnet:master Mar 12, 2016
@janvorli
janvorli deleted the complete-timed-wait-for-event branch March 12, 2016 02:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants