PlummersSoftwareLLC / Primes

Prime Number Projects in C#/C++/Python
https://plummerssoftwarellc.github.io/PrimeView/
2.43k stars 574 forks source link

update dart solutions to dart3 #925

Closed mmcdon20 closed 1 year ago

mmcdon20 commented 1 year ago

Description

Updates the dart solutions to dart 3.

The core solution is the same, but I did update the parallel code in the following ways.

  1. The result from the work function is now a Record instead of a Map. This has better type safety and it is no longer necessary to do a typecast, for example message['passes'] as int can now be written as message.passes.

  2. I am now using Isolate.run instead of Isolate.spawn. With spawn you had to create a ReceivePort in order to send the result back from the spawned isolate, run is a newer api that simply returns the result as a Future without the need to create a ReceivePort, which simplifies the code somewhat.

Contributing requirements

rbergen commented 1 year ago

@mmcdon20 It seems CI on this PR fails, on Dart/solution_1 to be precise. This is the relevant snippet of the logs:

#7 [build 1/6] FROM docker.io/library/dart:3.0.0@sha256:36cca0cee57b7f49a5fd1d47ab4bad4dec48b650aac4013b6c9d9a6f0f0a4755
#7 extracting sha256:c352dfb67360115842446d4b692ae59647ad60ab7782acf9c4e34b43437df004
#7 extracting sha256:c352dfb67360115842446d4b692ae59647ad60ab7782acf9c4e34b43437df004 6.3s done
#7 DONE 9.9s

#10 [build 2/6] WORKDIR /app
#10 DONE 0.9s

#11 [build 3/6] COPY pubspec.* ./
#11 DONE 0.0s

#12 [build 4/6] RUN pub get
#12 0.112 /bin/sh: 1: pub: not found
#12 ERROR: process "/bin/sh -c pub get" did not complete successfully: exit code: 127
------
 > [build 4/6] RUN pub get:
#12 0.112 /bin/sh: 1: pub: not found
------
Dockerfile:4
--------------------
   2 |     WORKDIR /app
   3 |     COPY pubspec.* ./
   4 | >>> RUN pub get
   5 |     COPY . .
   6 |     RUN pub get --offline \
--------------------
ERROR: failed to solve: process "/bin/sh -c pub get" did not complete successfully: exit code: 127
Error: buildx failed with: ERROR: failed to solve: process "/bin/sh -c pub get" did not complete successfully: exit code: 127
mmcdon20 commented 1 year ago

They changed the command to dart pub get instead of pub get, sorry about that. Updated the dockerfile accordingly.

rbergen commented 1 year ago

That's ok. I didn't have to figure this out myself, CI did all the hard work there. :)