Skip to content
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
5 changes: 2 additions & 3 deletions dcli/lib/src/process/environment.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import 'package:dcli_core/dcli_core.dart';

import 'process/process_sync.dart';
// import 'process/process_sync.dart';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seemed like an used import so I commented it out for now.


/// Used internally to pass environment variables across an isolate
/// boundary when using [ProcessSync] to synchronously call a process.
class ProcessEnvironment {
factory ProcessEnvironment() =>
ProcessEnvironment._(envs, Env().caseSensitive);
factory ProcessEnvironment() => ProcessEnvironment._(envs, Env().caseSensitive);

ProcessEnvironment._(this.envVars, this.caseSensitive);

Expand Down
241 changes: 0 additions & 241 deletions dcli/lib/src/process/process/mailbox.dart

This file was deleted.

10 changes: 3 additions & 7 deletions dcli/lib/src/process/process/native_calls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,14 @@ class NativeCalls {
static final Object Function(int) _connectToPort = _initNativeConnectToPort();

/// Don't really know why but we go and find the
/// native dart method to connect to a prot.
/// native dart method to connect to a port.
static Object Function(int) _initNativeConnectToPort() {
final functions =
NativeApi.initializeApiDLData.cast<_DartApi>().ref.functions;
final functions = NativeApi.initializeApiDLData.cast<_DartApi>().ref.functions;

late Object Function(int) connectToPort;
for (var i = 0; functions[i].name != nullptr; i++) {
if (functions[i].name.toDartString() == 'Dart_NewSendPort') {
connectToPort = functions[i]
.function
.cast<NativeFunction<Handle Function(Int64)>>()
.asFunction();
connectToPort = functions[i].function.cast<NativeFunction<Handle Function(Int64)>>().asFunction();
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion dcli/lib/src/process/process/pipe_sync.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class PipeSync {
/// exit code do we return?
int? get exitCode => _rhsChannel.exitCode;

/// Run the two given process as defined by [lhsSettings] and [rhsSettings]
/// Run the two given process as defined by [lhsSettings] (left-hand-side settings) and [rhsSettings] (right-hand-side settings).
/// piping the input from the [lhsSettings] process into the [rhsSettings]
/// process.
///
Expand Down
20 changes: 11 additions & 9 deletions dcli/lib/src/process/process/process_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ import 'dart:convert';
import 'dart:isolate';
import 'dart:typed_data';

import 'mailbox.dart';
import 'package:native_synchronization/mailbox.dart';

import 'message.dart';
import 'process_sync.dart';
// import 'mailbox.dart';
import 'pipe_sync.dart';
// import 'process_sync.dart';

/// Send and Receive data to/from a process
/// running in an isolate using a pair of mailboxes.
Expand Down Expand Up @@ -82,12 +85,12 @@ class ProcessChannel {
late final StringConversionSink splitter;
late final ByteConversionSink decoder;

// TODO: this probably need to be int arrays so
// TODO DONE?: this probably need to be int arrays so
// we can handly binary data.
final List<List<int>> stdoutLines = <List<int>>[];
final List<List<int>> stderrLines = <List<int>>[];
int get sendAddress => send.rawAddress;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are no longer necessary.

int get responseAddress => response.rawAddress;
// int get sendAddress => send.rawAddress;
// int get responseAddress => response.rawAddress;

int? _exitCode;
int? get exitCode => _exitCode;
Expand Down Expand Up @@ -147,18 +150,17 @@ class ProcessChannel {

/// check the data has been sent to the spawned process
/// before we return
final response = send.takeOneMessage();
final response = send.take();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

if (response.isEmpty || response[0] != RECEIVED) {
throw ProcessSyncException(
'Expecting a write confirmation: got $response');
throw ProcessSyncException('Expecting a write confirmation: got $response');
}
}

void _fetch() {
Uint8List bytes;

/// drain the mailbox
bytes = response.takeOneMessage();
bytes = response.take();
_recieveFromIsolate(bytes);
// decoder.add(bytes);

Expand Down
Loading