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

Fix compilation on DMD v2.067 #992

Merged
merged 1 commit into from
Feb 27, 2015
Merged

Fix compilation on DMD v2.067 #992

merged 1 commit into from
Feb 27, 2015

Conversation

etcimon
Copy link
Contributor

@etcimon etcimon commented Feb 25, 2015

This also adds a fix for HashMap reallocation issue pointed out earlier.

@@ -760,7 +761,7 @@ final class LibasyncManualEvent : ManualEvent {
auto evloop = getEventLoop();
shared AsyncSignal sig = cast(shared AsyncSignal) signal;
if (!sig.trigger(evloop))
throw new Exception(sig.error);
return; //throw new Exception(sig.error);
Copy link
Contributor

Choose a reason for hiding this comment

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

In which situation could this happen ? Wouldn't an asset be better over a silent fail ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, that's an artifact when I was experimenting making this method nothrow

@s-ludwig
Copy link
Member

Still fails, because libasync.all doesn't exist.

@etcimon
Copy link
Contributor Author

etcimon commented Feb 26, 2015

Still fails, because libasync.all doesn't exist.

Yes, that one was removed recently in favor of just libasync

@Geod24
Copy link
Contributor

Geod24 commented Feb 26, 2015

It's in need for a rebase.

I still don't consider 7cca2ba as a good solution though, especially given the fact it turns an Exception into an Error.

@etcimon
Copy link
Contributor Author

etcimon commented Feb 26, 2015

I think the proper solution is to stop inheriting from Object.Monitor, stop using synchronized in fibers, and write a scopedLock!TaskMutex for it instead (so that fibers can be interrupted!)

@mihails-strasuns
Copy link
Contributor

turns an Exception into an Error

Into segmentation fault actually (with -release) ;)

@etcimon
Copy link
Contributor Author

etcimon commented Feb 26, 2015

Into segmentation fault actually (with -release) ;)

I got a strange segmentation fault in -release using dmd master with libasync (Windows). This isn't supposed to happen, what platform are you on.

@etcimon
Copy link
Contributor Author

etcimon commented Feb 26, 2015

Nevermind, that's actually what usually happens on assertion failures in release ^^

@etcimon
Copy link
Contributor Author

etcimon commented Feb 26, 2015

I hope this commit will settle the question :)

@s-ludwig
Copy link
Member

Sorry, but in this form this is not a solution. This is all public code and changing the inheritance like this is a breaking change. All breaking changes must at least go through a deprecation phase.

@etcimon
Copy link
Contributor Author

etcimon commented Feb 26, 2015

All breaking changes must at least go through a deprecation phase.

How do you deprecate broken code (on DMD 2.067)? Unless I wrap it in a static if version clause?

@etcimon
Copy link
Contributor Author

etcimon commented Feb 26, 2015

This new fix adds some features when running DMD <= 2.066, and removes other features for DMD 2.067 to make vibe.d compatible with it.

Unfortunately, it'll break anything that tries to run on DMD 2.067 with certain mutex uses, but that was already broken and is simply bubbling up from druntime.

I don't know how to deprecate it properly, but the changes for DMD >= 2.067 are as follows:

  • TaskMutex, RecursiveTaskMutex, TaskCondition are now detached from Object.Monitor on the inheritance tree
  • synchronized statement is unavailable as a consequence, it must be replaced with auto l = mutex.locked, or auto l = scopedLock(mutex) which returns a ScopedMutexLock
  • If using DMD >= 2.067, the with statement is also available as a convenience (it doesn't work on <= 2.066): with(mutex.locked) { /* synchronized */ }

@s-ludwig
Copy link
Member

What would have to be deprecated is the old API. This would for example be the whole TaskMutex class. A new class would then have to be added as a replacement. But maybe there is a more elegant path, too... maybe using some alias this trickery. But the final direction taken in Druntime needs to be clear first.

BTW, TaskMutex.locked is redundant and doesn't save much over m.scopedLock (UFCS). I'd remove it to avoid confusion.

@etcimon
Copy link
Contributor Author

etcimon commented Feb 26, 2015

Didn't think the UFCS would allow me to remove parenthesis.

So this last fix should be good, if you can merge the travis exclusion I'm sure we can see the whole thing go green.

@s-ludwig
Copy link
Member

I would have liked to keep the mutex changes separate from the libasync ones (defer it until the Druntime case is settled), but anyway, that can always be changed again before release. But the first commit still seems to contain merge errors (reverts some changes in the libevent driver), or was that intended (Travis still passes)?

@etcimon
Copy link
Contributor Author

etcimon commented Feb 26, 2015

But the first commit still seems to contain merge errors (reverts some changes in the libevent driver)

That was intentional, the changes I submitted are in a different direction and the nothrow / static assert(false) are unnecessary now. This fix doesn't affect the DMD <= 2.066.1 builds

I would have liked to keep the mutex changes separate from the libasync ones (defer it until the Druntime case is settled)

They allow libasync to run on 2.067, which is relevant to the pull :)

@etcimon
Copy link
Contributor Author

etcimon commented Feb 26, 2015

(Travis still passes)?

Travis passes on everything except the 4 versions that aren't supported by libasync (yet)

@s-ludwig
Copy link
Member

So did you make the changes in libevent.d on purpose? Why are they in the commit that fixes the libasync driver?

@etcimon
Copy link
Contributor Author

etcimon commented Feb 26, 2015

So did you make the changes in libevent.d on purpose? Why are they in the commit that fixes the libasync driver?

They're in the libasync driver pull because it must address the whole of the mutex issues in 2.067, where the proposed solution was to make the drivers nothrow. The libevent driver had a few added nothrows, which I removed because it seemed unnecessary given the fact that the new approach is to let the mutexes and drivers remain throwable.

I can revert the changes if you like.

@s-ludwig
Copy link
Member

I can revert the changes if you like.

No no, I think it's most probably a step in the right direction. It just seemed out of place in the commit order back then.

Made libevent default again

Fix dub.json

Remove artifact

Add assertions to replace caught exceptions

Update version for travis tests

Remove libasync.all

Add sorting import for redis test

Implement throwable task mutexes

Removed memory changes

fix segfault

Lock using with statement in synchronized-like syntax

Add compatibility with previous DMD versions

Add deprecation messages for TaskMutex & RecursiveTaskMutex

update test
@etcimon
Copy link
Contributor Author

etcimon commented Feb 27, 2015

Green!

@s-ludwig
Copy link
Member

Yay!

s-ludwig added a commit that referenced this pull request Feb 27, 2015
@s-ludwig s-ludwig merged commit c3e0a8c into vibe-d:master Feb 27, 2015
@s-ludwig
Copy link
Member

And thanks of course!

@etcimon etcimon deleted the fix-libasync-new-dmd branch February 27, 2015 19:43
@trusted bool tryLock();
@trusted void lock();
@trusted void unlock();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This won't work with synchronized and really looks like an abysmal solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants