Commit graph

47 commits

Author SHA1 Message Date
Sönke Ludwig f8a6044dba Avoid modern contract syntax. 2020-12-18 14:11:29 +01:00
Sönke Ludwig 34703d412d Make ScopedMutexLock nothrow.
Wrong order of lock/unlock calls are programming errors and should be treated as such.
2020-12-12 10:11:17 +01:00
Sönke Ludwig 44f13592d3 Remove dead code. 2020-03-16 14:14:50 +01:00
Sönke Ludwig 5640516ba8 Remove SpinLock and use core.sync.mutex.Mutex instead.
The places that used it showed too much contention in load tests, so that the spin lock was more expensive that the regular OS mutex/futex.
2019-09-19 11:25:14 +02:00
Sönke Ludwig a202d33b3e Fix a (harmless) race-condition.
ThreadLocalWaiter.unused may only be accessed from the owner thread.
2019-04-13 17:01:50 +02:00
Sönke Ludwig 1a463cafc9 Make TaskCondition.wait/notify/notifyAll nothrow. 2019-01-26 18:04:50 +01:00
Sönke Ludwig cccf45cfea Add a motivational introduction to the sync module.
Especially mention the issues of using `core.sync.*`.
2019-01-14 10:22:13 +01:00
Sönke Ludwig 6c0bdf2976 Add documentation and unittest example to scopedMutexLock. 2019-01-14 10:22:12 +01:00
Sönke Ludwig fb64c07d3c Make scopedMutexLock work with InterruptibleTaskMutex. 2019-01-14 10:22:12 +01:00
Sönke Ludwig 452fa411c2 Avoid overload conflict when using TaskMutex together with InterruptibleTaskCondition. 2019-01-14 10:22:12 +01:00
Sönke Ludwig ffa5bd5c58 Add a trap to detect invalid uses of InterruptibleTaskMutex in conjunction with synchronized. 2019-01-14 10:22:12 +01:00
Hiroki Noda a408aac808 Use monotonic clock for timeout 2018-12-24 06:22:53 +09:00
Sönke Ludwig c3272f7d1f Fix assertion in SpinLock when called from a signal handler.
Since the signal handler can be called in any thread of the application, it may happen so in a non-D thread where Thread.getThis() returns null. This change works around this and also removes the need to call SpinLock.setup on thread startup.
2018-10-30 12:39:08 +01:00
Boris-Barboris 788973f628 same measures for ManualEvent 2018-03-30 12:59:24 +00:00
Boris-Barboris bf9d736c4f another way around. Fix typo in comment. 2018-03-30 10:06:44 +00:00
Boris-Barboris 489b35539b fix comparison in doWait 2018-03-30 09:28:45 +00:00
Boris-Barboris a840c51c5d fix integer overflow protection absence for LocalManualEvent 2018-03-30 09:17:09 +00:00
Sönke Ludwig 2c63aa5c5c Allow destructors to run in foreign threads. Fixes #69.
This change modifies destructors to anticipate that they can be called form a foreign thread if the GC is involved. The actual release of the reference will then happen deferred in the original thread.
2018-03-16 18:06:53 +01:00
Sönke Ludwig 9fe9783443 Convert Waitable from struct to pure template to avoid heap closures.
Also fixes a case where ThreadLocalWaiter.emitSingle overlaps a call to .emit.
2017-09-27 16:41:11 +02:00
Boris-Barboris a590de154a fix deadlocks, caused by second m_locks increment 2017-08-28 21:58:08 +00:00
Sönke Ludwig 59ac459cdf Mark all synchronization classes final.
Those classes are not meant as being derived from.
2017-07-23 14:57:48 +02:00
Sönke Ludwig be0de0a733 Add assertions for uninitialized LocalManualEvents. 2017-07-20 16:52:35 +02:00
Sönke Ludwig f6736d13ab Add test that reproduces the LocalManualEvent copy bug. 2017-07-20 16:14:47 +02:00
Sönke Ludwig 100dfc30ee Add test that triggers the former bug in ThreadLocalWaiter.emit() and ensures FIFO emit order. 2017-07-20 16:10:18 +02:00
Sönke Ludwig a4b36f08d3 Fix multiple issues in (Local)ManualEvent.
- Copying LocalManualEvent now works correctly, using reference counting
- ManualEvent correctly pins the reference to the thread-local waiter until it has finished emitting it
- ThreadLocalWaiter uses a doubly-linked list to manage task waiters (more efficient deletion, FIFO trigger order)
- Fixed a bug in ThreadLocalWaiter.emit() where the head element of the iterated list might already have stopped waiting, resulting in an invocation of a dangling TaskWaiter pointer
2017-07-20 15:57:44 +02:00
Sönke Ludwig 4bccf6fcb5
Use StackSList for ThreadLocalWaiter and add simple loop detection.
This will have to be adjusted to use a circular list with the possibility to insert a pivot element, so that consumption of waiters is safe in all cases (see the comment at 1265).
2017-07-19 14:54:33 +02:00
Sönke Ludwig fcf98c2016 Merge branch 'master' into trailing-whitespace 2017-07-19 00:08:33 +02:00
Sönke Ludwig 7efb496208
Fix double-free of ThreadLocalWaiter in ManualEvent.
Also adds assertions and a randomized multi-thread test to rule out similar issues with a higher confidence.
2017-07-15 18:16:13 +02:00
Sebastian Wilzbach 8f89733a86 Remove all trailing whitespace
sed 's/[ \t]*$//' -i **/*.d
2017-07-03 12:19:27 +02:00
Sönke Ludwig e3c680b0ce
Add assertion to ManualEvent to check for failure of creating event handles. 2017-03-27 16:32:24 +02:00
Sönke Ludwig f9372446b1 Improve the sync module.
- Change the API of Monitor to work without a callback
- Add ManualEvent.emitSingle
2017-02-22 17:42:20 +01:00
Sönke Ludwig 8f6c4dd536
Fix LocalTaskSemaphore.
Fixes a potential hang, potential over-use of lock slots and only needs a single LocalManualEvent now instead of one created for each wait.
2017-01-30 10:07:06 +01:00
Sönke Ludwig b391ebabbe
Add more specific assertion for SpinLock initialization. 2017-01-27 22:50:57 +01:00
Sönke Ludwig 5f980acefd
Upgrade to latest eventcore. 2017-01-25 21:04:13 +01:00
Sönke Ludwig 9d4e8086ff Make the callback type the first argument to Waitable!(). 2017-01-16 00:23:37 +01:00
Sönke Ludwig f015662a94 TCPConnection and async improvements.
- asyncAwaitAny now takes the callback type, so that parameter storage classes are handled correctly
- Implement TCPConnection.remoteAddress/localAddress
- Implement TCPConnection.tcpNoDelay, keepAlive and readTimeout
- Implement timeout handling for TCPConnection.waitForData
2017-01-15 20:59:36 +01:00
Sönke Ludwig fdfbb55aa8 Re-implement ManualEvent.
This simplifies the logic by separating thread local notifications from cross-thread notifications, as well as replacing lockless operations by a spin lock. The thread local variant of ManualEvent is now also separated into a LocalManualEvent type.
2017-01-13 22:24:18 +01:00
Sönke Ludwig ece639ee01 Improve assertion/test coverage of ManualEvent. 2017-01-11 17:46:36 +01:00
Sönke Ludwig 1b2c0f33d1 Fix timeout handling in ManualEvent.
The timeout could was re-applied in every loop iteration of the wait routine, possibly causing an infinite loop.
2016-12-19 20:19:58 +01:00
Sönke Ludwig 5e89ac4e91 Safe-ify sync module. 2016-11-02 21:01:09 +01:00
Sönke Ludwig 1eb06c4b1a Mark ManualEvent's interface as safe. 2016-10-25 08:55:48 +02:00
Sönke Ludwig e294d24a4b Update for latest eventcore version. 2016-10-05 14:40:29 +02:00
Sönke Ludwig 914e9ad894 Change debug version "VibeMutexPrint" -> "VibeMutexLog". 2016-10-04 17:53:40 +02:00
Sönke Ludwig 1005f5c674 Fix all ManualEvent related tests. 2016-06-17 22:33:04 +02:00
Sönke Ludwig e8ba981263 Draft proper shared semantics for ManualEvent. 2016-06-15 18:21:33 +02:00
Sönke Ludwig 3b0e4e0452 Big refactoring step.
- Moves a lot of stuff from vibe.core.core to vibe.core.task
- Introduces TaskScheduler to unify the scheduling process
- Refines how tasks are scheduled and processed (can push to the front of the task queue and uses a marker task to keep track of the spot up to which to process)
- Start to add proper support for task interrupts and timeouts by properly cancelling in-flight async operations
- Work on ManualEvent - still not functional for the shared case
- Implement proper IP address parsing in NetworkAddress
2016-06-14 08:01:03 +02:00
Sönke Ludwig 7e2d1dd038 Initial commit.
The library is able to support simple TCP servers in the current state. The API is still mostly compatible with mainline vibe.d, but the driver systen has been replaced by the eventcore library and sockets/files/timers/... are now structs with automatic reference counting instead of GC collected classes. The stream interfaces have been removed for now.
2016-03-01 20:30:42 +01:00