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

Trivial improvements #198

Merged
merged 5 commits into from
Mar 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
1.9.0 - 2020-
==================

- Implemented priority based task scheduling - [pull #196][issue196], [pull #197][issue197]
- Each task can be given a non-default priority that controls the relative frequency with which the task gets resumed in concurrent situations
- Events are now handled according to the calling task's priority instead of being handled immediately (can be reverted by defining a `VibeHighEventPriority` version)
- Fixeed a bogus contract violation error in `Timer.rearm` - [pull #195][issue195]

[issue195]: https://github.com/vibe-d/vibe-core/issues/195
[issue196]: https://github.com/vibe-d/vibe-core/issues/196
[issue197]: https://github.com/vibe-d/vibe-core/issues/197


1.8.1 - 2019-12-17
==================

Expand All @@ -9,7 +22,7 @@
1.8.0 - 2019-12-07
==================

- Adds a new path segment API that works without GC allocations (`GenericPath.bySegment2`/`.head2`) - this will replace the old API in version 2.x.x of the library - [pull #179][issue179]
- Added a new path segment API that works without GC allocations (`GenericPath.bySegment2`/`.head2`) - this will replace the old API in version 2.x.x of the library - [pull #179][issue179]
- Added `GenericPath.byPrefix` to iterate over all acestor paths from root to leaf - [pull #181][issue181]
- Fixed a bug with unitialized `YieldLock` instances (which can happen even with `@disable this()`) - [pull #180][issue180]
- Heavily improved performance of `readFileUTF8` for large files by using a more efficient `sanitizyUTF8` implementation - [pull #182][issue182]
Expand Down
14 changes: 0 additions & 14 deletions source/vibe/core/core.d
Original file line number Diff line number Diff line change
Expand Up @@ -1507,20 +1507,6 @@ private void setupSignalHandlers()
// per process setup
shared static this()
{
version(Windows){
version(VibeLibeventDriver) enum need_wsa = true;
else version(VibeWin32Driver) enum need_wsa = true;
else enum need_wsa = false;
static if (need_wsa) {
logTrace("init winsock");
// initialize WinSock2
import core.sys.windows.winsock2;
WSADATA data;
WSAStartup(0x0202, &data);

}
}

s_isMainThread = true;

// COMPILER BUG: Must be some kind of module constructor order issue:
Expand Down
9 changes: 7 additions & 2 deletions source/vibe/core/net.d
Original file line number Diff line number Diff line change
Expand Up @@ -770,8 +770,13 @@ mixin(tracer);
switch (res[1]) {
default:
throw new Exception("Error writing data to socket.");
case IOStatus.ok: break;
case IOStatus.disconnected: break;
case IOStatus.ok:
assert(mode != IOMode.all || res[2] == bytes.length);
break;
case IOStatus.disconnected:
if (mode == IOMode.all && res[2] != bytes.length)
throw new Exception("Connection closed while writing data.");
break;
}

return res[2];
Expand Down
3 changes: 0 additions & 3 deletions source/vibe/core/sync.d
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,6 @@ final class InterruptibleTaskMutex : Lockable {
void unlock() nothrow { m_impl.unlock(); }
}

version (VibeLibevDriver) {} else // timers are not implemented for libev, yet
unittest {
runMutexUnitTests!InterruptibleTaskMutex();
}
Expand Down Expand Up @@ -475,7 +474,6 @@ final class RecursiveTaskMutex : core.sync.mutex.Mutex, Lockable {
override void unlock() { m_impl.unlock(); }
}

version (VibeLibevDriver) {} else // timers are not implemented for libev, yet
unittest {
runMutexUnitTests!RecursiveTaskMutex();
}
Expand Down Expand Up @@ -507,7 +505,6 @@ final class InterruptibleRecursiveTaskMutex : Lockable {
void unlock() { m_impl.unlock(); }
}

version (VibeLibevDriver) {} else // timers are not implemented for libev, yet
unittest {
runMutexUnitTests!InterruptibleRecursiveTaskMutex();
}
Expand Down
7 changes: 5 additions & 2 deletions tests/vibe.core.net.1376.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
name "tests"
description "TCP disconnect task issue"
dependency "vibe-core" path="../"
versions "VibeDefaultMain"
+/
module test;

import vibe.core.core;
import vibe.core.net;
import core.time : msecs;

shared static this()
void main()
{
auto l = listenTCP(0, (conn) {
auto td = runTask!TCPConnection((conn) {
Expand Down Expand Up @@ -39,4 +38,8 @@ shared static this()
sleep(50.msecs);
exitEventLoop();
});

runApplication();

l.stopListening();
}
6 changes: 5 additions & 1 deletion tests/vibe.core.net.1726.d
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ void performTest(bool reverse)
auto wt = runTask!TCPConnection((conn) {
sleep(reverse ? 100.msecs : 20.msecs); // give the connection time to establish
try {
conn.write(buf);
// write enough to let the connection block long enough to let
// the remote end close the connection
// NOTE: on Windows, the first write() can actually complete
// immediately, but the second one blocks
foreach (i; 0 .. 2) conn.write(buf);
assert(false, "Expected write() to throw an exception.");
} catch (Exception) {
write_ex = true;
Expand Down