패키지, 저장소 및 앱 카테고리 검색

패키지 상세v3.2.1

computer

compute()와 유사한 API를 갖춘 사용하기 쉬운 동시 작업자 풀입니다.

AndroidiOSmacOSWindowsLinux
30일 다운로드
1.4천
좋아요
63
Pub 점수
160

패키지 설치

flutter pub add computer

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

컴퓨터 패키지는 Dart에서 간단하고 효율적인 동시 작업자 풀을 제공하며, Flutter의 내장된 compute 함수와 유사한 compute() API를 제공합니다. CPU 집약적인 작업을 메인 고립체 외부에서 실행할 수 있게 해 주어 앱의 반응성을 향상시킵니다. 사용이 쉬우며 복잡한 동시성 관리를 추상화하면서도 Android, iOS, macOS, Windows, Linux 등 다양한 플랫폼을 지원합니다. 데이터 파싱, 이미지 조작, 무거운 계산 등의 백그라운드 처리에 적합합니다.

사용 사례

  • 백그라운드에서 CPU 집약적인 작업 실행
  • UI를 차단하지 않고 대규모 데이터 세트 처리
  • 이미지 또는 파일 변환 수행
  • 장시간 실행되는 수학 계산 수행 중
  • 집중적인 작업 중 앱 성능 향상

주요 기능

  • 간단한 compute() API
  • 크로스 플랫폼 지원
  • 자동 워커 풀 관리
  • 경량이며 통합이 쉬움
  • 내장된 오류 처리 및 재시도

적합한 대상

  • 백그라운드 계산이 필요한 개발자
  • 집중적인 데이터 처리를 하는 앱
  • 중량 작업 중 반응형 UI가 필요한 프로젝트
  • Flutter의 compute에 대한 즉시 사용 가능한 대안을 원하는 팀
  • 여러 데스크톱 및 모바일 플랫폼을 대상으로 하는 애플리케이션

고려 사항

  • 입출력 중심 작업에 적합하지 않습니다
  • 워커 동작에 대한 제한된 사용자 정의
  • 많은 동시 작업 시 더 많은 메모리를 사용할 수 있음
  • 네트워크 작업보다는 CPU 집약적인 작업에 가장 적합합니다
  • 고립 간 대규모 데이터 전송을 주의 깊게 처리해야 합니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Computer

Computer is a lightweight library for concurrent computations, which provides Flutter's compute like API.

Features

  • Easy to use API
  • No overhead on creating & releasing isolates for each task. Workers initialized on start and ready to solve your tasks
  • Strictly defined number of workers

Note

Computer.shared() is a singleton, use Computer.create() to create new instances

How to use

Computer provides just 3 methods

turnOn()

Before using the Computer you need to turnOn it. This will create workers and initialize them. Then you may use compute() method.

final computer = Computer.create(); //Or Computer.shared()

await computer.turnOn(
  workersCount: 4, // optional, default 2
  verbose: false, // optional, default false
);
compute()

compute will execute your function inside one of the workers. Function may be async. The callback argument must be a top-level or static method of a class.

final result = await computer.compute(
  fib,
  param: 45, // optional
);
turnOff()

If you don't need workers anymore, you can turnOff the Computer. It will destroy workers.

await computer.turnOff();
Errors

ComputerError the parent error for all errors/exceptions in this package

class ComputerError implements Exception {
  final String message;
}

RemoteExecutionError shows up when something goes wrong in task

class RemoteExecutionError extends ComputerError {
  final Capability taskCapability;
}

CancelExecutionError shows up when turnOff is called but task is processing

class CancelExecutionError extends ComputerError {
  final Capability taskCapability;
}

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트