Merge pull request #198 from vibe-d/trivial

Trivial improvements
This commit is contained in:
Sönke Ludwig 2020-03-18 15:31:03 +01:00 committed by GitHub
commit 3e649f0024
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 31 additions and 23 deletions

View file

@ -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 1.8.1 - 2019-12-17
================== ==================
@ -9,7 +22,7 @@
1.8.0 - 2019-12-07 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] - 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] - 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] - Heavily improved performance of `readFileUTF8` for large files by using a more efficient `sanitizyUTF8` implementation - [pull #182][issue182]

View file

@ -1507,20 +1507,6 @@ private void setupSignalHandlers()
// per process setup // per process setup
shared static this() 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; s_isMainThread = true;
// COMPILER BUG: Must be some kind of module constructor order issue: // COMPILER BUG: Must be some kind of module constructor order issue:

View file

@ -770,8 +770,13 @@ mixin(tracer);
switch (res[1]) { switch (res[1]) {
default: default:
throw new Exception("Error writing data to socket."); throw new Exception("Error writing data to socket.");
case IOStatus.ok: break; case IOStatus.ok:
case IOStatus.disconnected: break; 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]; return res[2];

View file

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

View file

@ -2,7 +2,6 @@
name "tests" name "tests"
description "TCP disconnect task issue" description "TCP disconnect task issue"
dependency "vibe-core" path="../" dependency "vibe-core" path="../"
versions "VibeDefaultMain"
+/ +/
module test; module test;
@ -10,7 +9,7 @@ import vibe.core.core;
import vibe.core.net; import vibe.core.net;
import core.time : msecs; import core.time : msecs;
shared static this() void main()
{ {
auto l = listenTCP(0, (conn) { auto l = listenTCP(0, (conn) {
auto td = runTask!TCPConnection((conn) { auto td = runTask!TCPConnection((conn) {
@ -39,4 +38,8 @@ shared static this()
sleep(50.msecs); sleep(50.msecs);
exitEventLoop(); exitEventLoop();
}); });
runApplication();
l.stopListening();
} }

View file

@ -30,7 +30,11 @@ void performTest(bool reverse)
auto wt = runTask!TCPConnection((conn) { auto wt = runTask!TCPConnection((conn) {
sleep(reverse ? 100.msecs : 20.msecs); // give the connection time to establish sleep(reverse ? 100.msecs : 20.msecs); // give the connection time to establish
try { 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."); assert(false, "Expected write() to throw an exception.");
} catch (Exception) { } catch (Exception) {
write_ex = true; write_ex = true;