Commit Graph
17 Commits
Author SHA1 Message Date
Peter Adams 43931b7a7d Make all imports of CNIOLinux conditional on OS (#1704)
Motivation:

Some users are including NIO in Xcode workspaces
rather than using SPM.  When this is done, if all
imports of CNIOLinux are conditional they can
remove this project from their workspace.

Modifications:

Make all imports of CNIOLinux conditional on Linux,
Android or FreeBSD

Result:

No user visible change.
2020-12-16 10:41:56 +00:00
buttafaceandCory Benfield 44d67ba4e0 Update and finish Android port. (#1695)
Motivation:

Be able to run and test swift-nio on Android.

Modifications:

- Remove the custom ifaddrs and use the one from the Android NDK instead.
- Enable a bunch of conditionally-compiled code for Android.
- Add a handful of constants and other Android declarations.
- Cast some types because of mismatches specific to Android.

Result:

Most tests pass on Android AArch64 and ARMv7.

Co-authored-by: Cory Benfield <lukasa@apple.com>
2020-11-27 11:16:11 +00:00
Saleem AbdulrasoolandCory Benfield 245ce96490 NIO: implement network interface enumeration for Windows (#1647)
Partially implement network interface enumeration.  This is sufficient
to build up the structures for basic operations.  Although the interface
information is incomplete, this provides enough structure to continue
porting the rest of the NIO interfaces.

Co-authored-by: Cory Benfield <lukasa@apple.com>
2020-10-28 16:20:02 +00:00
Cory Benfield f9552beffa Replace NIONetworkInterface with NIONetworkDevice. (#1622)
Motivation:

NIONetworkInterface was a useful type, but its implementation was fairly
fatally flawed in a number of ways. While we could have lived with the
awkward type construction (it's a class, which isn't the semantic we
want), the ultimate flaw is that you cannot create a NIONetworkInterface
for an interface that does not have an IP address.

That's not helpful, given that it's not uncommon for an interface to not
have an IP address!

Modifications:

- Deprecate NIONetworkInterface
- Add NIONetworkDevice
- Provide new methods on MulticastChannel that use NIONetworkDevice
  instead of NIONetworkInterface.
- Provide default implementations of new MulticastChannel protocol
  requirements.
- Implement new MulticastChannel protocol requirements.
- Update the tests.

Result:

Devices will be able to reflect network devices without IP addresses.
2020-08-24 09:37:27 +01:00
Gautier DelormeandJohannes Weiss 0695662d7d fix cores count in containers (#1518)
Motivation:

The current System.coreCount implementation relies on _SC_NPROCESSORS_ONLN so isn't cgroups aware which might have a bad impact for apps runnings in containers (e.g. Docker, Kubernetes, Amazon ECS...).

Modifications:

- Changed System.coreCount on Linux only to make it read from CFS quotas and cpusets when present.
- Removed incorrect precondition in Sources/NIO/LinuxCPUSet.swift

Result:

System.coreCount returns correct values when apps run in containers.

Co-authored-by: Johannes Weiss <johannesweiss@apple.com>
2020-05-15 10:09:35 +01:00
Saleem Abdulrasool 2673be6ae3 NIO: move comment to right location (NFC) (#1452)
Move the block comment to the right location before the function it
describes.
2020-03-17 09:31:00 +00:00
d3d7589a29 NIO: implement core counting on Windows (#1448)
* NIO: implement core counting on Windows

Implement the core counting logic for Windows, which does not support
`sysconf`.  It uses the Windows SDK to get the processor topology and
computes the core count from the topology.

Co-authored-by: Cory Benfield <lukasa@apple.com>
Co-authored-by: Johannes Weiss <johannesweiss@apple.com>
2020-03-16 18:41:58 +00:00
Johannes Weiss 9b78557aff kick off NIO2 (#678)
Motivation:

NIO2 development starts now.

Modifications:

Made NIO Swift 5-only for everything else see docs/public-api-changes-NIO1-to-NIO2.md

Result:

NIO2 development can start.
2018-12-07 21:15:34 +00:00
Johannes Weiss 035962e6b6 EventLoop.assertInEventLoop and preconditionInEventLoop (#644)
Motivation:

Dispatch can only precondition that code is run from a certain queue, it
can't return if code is running on a certain queue.
To support that this introduces new EventLoop.assertInEventLoop and
EventLoop.preconditionInEventLoop methods instead of
assert(eventLoop.inEventLoop).

Modifications:

add EventLoop.assertInEventLoop and EventLoop.preconditionInEventLoop

Result:

better support for Network.framework in NIOTS
2018-11-05 09:50:33 +00:00
Albert Aleksieiev a59293cbcd add Android support (#609)
### Motivation:

make swift-nio compatible with Android, and pass all test in Android.

### Modifications:

* add missed `ifaddrs` implementation
* add missed thread related functions - `CNIOLinux_pthread_getname_np`, `CNIOLinux_pthread_setaffinity_np` and `CNIOLinux_pthread_getaffinity_np`
* fix types incositency between Linux and Android, e.g. `Epoll.swift` class
* make bytes counter explicitely 64bits to avoid overflow on 32bit, in `PendingWritesManager.swift` and `PendingDatagramWritesState.swift`
* fix issue with Unix domain socket, first byte need to be zero in Android
* several incosistency fixes between Linux and Android api.

### Result:

now swift-nio works on Android. All tests passed!
2018-09-27 11:32:43 +01:00
Lev Walkin 5347ab3e9f use a standard way to determine processor count (#496) 2018-07-03 11:45:19 +01:00
Cory Benfield ab4032c4eb Suppress compiler warnings in release mode. (#179)
Motivation:

There's no reason for us to emit compiler warnings.

Modifications:

Remove use of _isDebugAssertConfiguration to guard code, instead
use a hand-rolled hacky solution on top of assert.

Result:

Fewer warnings, more sadness.
2018-03-16 23:53:16 +09:00
Cory Benfield f3f37af4ae Support enumerating network interfaces. (#47)
Motivation:

When writing programs that use networks, particularly if you want to
perform multicast joins, it's extremely important to be able to query
network interfaces and get results.

Modifications:

Add support for querying interfaces using getifaddrs and wrap those query
results in a Swift class.

Result:

Users will be able to enumerate the interfaces on their machine.
2018-03-03 09:04:57 +09:00
Norman Maurer a8f0dcf0f5 Use computed property for System.coreCount
Motivation:

We should use a computed property to be more swifty.

Modifications:

Replace function with computed property

Result:

More swifty code.
2018-02-11 13:11:54 +01:00
Norman Maurer e1bf447a9a Replace usage of Foundation.Thread with our own Thread that just used…
* Replace usage of Foundation.Thread with our own Thread that just used pthread

* Address comments

* some more docs / comments

* Address comments of cory
2018-02-06 11:45:57 +01:00
Max (Swift) Moiseev 973a96004d Get rid of free functions
* Lift the EventLoopFuture.== into the type extension and add the Equatable conformance

* Get rid of the only public free function systemCoreCount
2018-01-30 10:41:44 -08:00
Cory Benfield 92634a68fb Add utility for detecting core count. 2018-01-22 12:05:43 +00:00