पैकेज, रिपॉज़िटरी और ऐप श्रेणियाँ खोजें

पैकेज विवरणv3.2.1

computer

समानांतर कार्यकर्ता के लिए आसान उपयोग करने वाला पूल, compute() जैसा API।

AndroidiOSmacOSWindowsLinux
30-दिन डाउनलोड
1.4 हज़ार
लाइक
63
Pub अंक
160

पैकेज इंस्टॉल करें

flutter pub add computer

पैकेज अवलोकन

सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।

कंप्यूटर पैकेज डार्ट में सरल, कुशल समानांतर कार्यकर्ता स्थान प्रदान करता है, जिसमें फ्लटर के एक्सबिल्ट कंप्यूट फ़ंक्शन के समान compute() API होता है। यह मुख्य इसोलेट से बाहर एमएसई-भारी कार्यक्रम चलाने की अनुमति देता है, जिससे ऐप की प्रतिक्रिया सुधरती है। उपयोग में आसान बनाने के लिए डिज़ाइन किया गया है, जिसमें जटिल समानांतर प्रबंधन को छिपाया गया है, और एंड्रॉइड, आईओएस, मैकओएस, विंडोज और लिनक्स जैसे विभिन्न प्लेटफॉर्म का समर्थन करता है। डेटा विश्लेषण, छवि संसाधन या भारी गणना जैसे पृष्ठभूमि प्रसंस्करण के लिए उपयुक्त है।

उपयोग

  • पृष्ठभूमि में CPU-भारी संचालन चलाएं
  • UI को ब्लॉक किए बिना बड़े डेटासेट की प्रोसेसिंग
  • चित्र या फ़ाइल परिवर्तन करना
  • लंबे समय तक चलने वाली गणितीय गणना कर रहे हैं
  • तीव्र कार्यक्रमों के दौरान ऐप प्रदर्शन में सुधार करना

मुख्य विशेषताएँ

  • सरल compute() API
  • क्रॉस-प्लेटफ़ॉर्म समर्थन
  • स्वचालित कार्य दल प्रबंधन
  • हल्का और एकीकरण में आसान
  • निर्मित त्रुटि प्रतिकार और पुनर्प्रयास

इनके लिए उपयुक्त

  • पृष्ठभूमि गणना की आवश्यकता वाले विकासकर्ता
  • तीव्र डेटा प्रसंस्करण वाले ऐप्स
  • भारी लोड के दौरान प्रतिक्रियाशील UI की आवश्यकता वाले प्रोजेक्ट
  • Flutter के compute का एक ड्रॉप-इन विकल्प चाहने वाली टीमें
  • कई डेस्कटॉप और मोबाइल प्लेटफॉर्म के लिए लक्षित अनुप्रयोग

विचार योग्य बातें

  • I/O बाध्य कार्यों के लिए उपयुक्त नहीं
  • कार्यकर्ता के व्यवहार का सीमित कस्टमाइज़ेशन
  • बहुत सारे समानांतर कार्यों के साथ अधिक मेमोरी का उपयोग कर सकता है
  • 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;
}

श्रेणियाँ

सोर्स रिपॉज़िटरी

इस पैकेज का उपयोग करने वाले प्रोजेक्ट