Skip to content
Merged
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
30 changes: 30 additions & 0 deletions Sources/NIOEmbedded/Embedded.swift
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,36 @@ public final class EmbeddedEventLoop: EventLoop, CustomStringConvertible {
return
}

public func _executeIsolatedUnsafeUnchecked(_ task: @escaping () -> Void) {
// Because of the way EmbeddedEL works, we can just delegate this directly
// to execute.
self.execute(task)
}

public func _submitIsolatedUnsafeUnchecked<T>(_ task: @escaping () throws -> T) -> EventLoopFuture<T> {
// Because of the way EmbeddedEL works, we can delegate this directly to schedule. Note that I didn't
// say submit: we don't have an override of submit here.
self.scheduleTask(deadline: self._now, task).futureResult
}

@discardableResult
public func _scheduleTaskIsolatedUnsafeUnchecked<T>(
deadline: NIODeadline,
_ task: @escaping () throws -> T
) -> Scheduled<T> {
// Because of the way EmbeddedEL works, we can delegate this directly to schedule.
self.scheduleTask(deadline: deadline, task)
}

@discardableResult
public func _scheduleTaskIsolatedUnsafeUnchecked<T>(
in delay: TimeAmount,
_ task: @escaping () throws -> T
) -> Scheduled<T> {
// Because of the way EmbeddedEL works, we can delegate this directly to schedule.
self.scheduleTask(in: delay, task)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: do we want to add the same "because of the way EmbeddedEL works..." comment here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I'll add that

}

deinit {
self.checkCorrectThread()
precondition(scheduledTasks.isEmpty, "Embedded event loop freed with unexecuted scheduled tasks!")
Expand Down
Loading