• Stars
    star
    261
  • Rank 156,630 (Top 4 %)
  • Language
    C#
  • License
    MIT License
  • Created about 11 years ago
  • Updated 29 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Make sure your asynchronous operations show up to work on time

NuGet Stats Build Code Coverage #yourfirstpr


Punchclock: A library for managing concurrent operations

Punchclock is the low-level scheduling and prioritization library used by Fusillade to orchestrate pending concurrent operations.

What even does that mean?

Ok, so you've got a shiny mobile phone app and you've got async/await. Awesome! It's so easy to issue network requests, why not do it all the time? After your users one-🌟 you for your app being slow, you discover that you're issuing way too many requests at the same time.

Then, you try to manage issuing less requests by hand, and it becomes a spaghetti mess as different parts of your app reach into each other to try to figure out who's doing what. Let's figure out a better way.

So many words, gimme the examples

var wc = new WebClient();
var opQueue = new OperationQueue(2 /*at a time*/);

// Download a bunch of images
var foo = opQueue.Enqueue(1, 
    () => wc.DownloadFile("https://example.com/foo.jpg", "foo.jpg"));
var bar = opQueue.Enqueue(1, 
    () => wc.DownloadFile("https://example.com/bar.jpg", "bar.jpg"));
var baz = opQueue.Enqueue(1, 
    () => wc.DownloadFile("https://example.com/baz.jpg", "baz.jpg"));
var bamf = opQueue.Enqueue(1, 
    () => wc.DownloadFile("https://example.com/bamf.jpg", "bamf.jpg"));

// We'll be downloading the images two at a time, even though we started 
// them all at once
await Task.WaitAll(foo, bar, baz, bamf);

Now, in a completely different part of your app, if you need something right away, you can specify it via the priority:

// This file is super important, we don't care if it cuts in line in front
// of some images or other stuff
var wc = new WebClient();
await opQueue.Enqueue(10 /* It's Important */, 
    () => wc.DownloadFileTaskAsync("http://example.com/cool.txt", "./cool.txt"));

What else can this library do

  • Cancellation via CancellationTokens or via Observables
  • Ensure certain operations don't run concurrently via a key
  • Queue pause / resume

Contribute

Punchclock is developed under an OSI-approved open source license, making it freely usable and distributable, even for commercial use. Because of our Open Collective model for funding and transparency, we are able to funnel support and funds through to our contributors and community. We ❀ the people who are involved in this project, and we’d love to have you on board, especially if you are just getting started or have never contributed to open-source before.

So here's to you, lovely person who wants to join us β€” this is how you can support us:

More Repositories

1

refit

The automatic type-safe REST library for .NET Core, Xamarin and .NET. Heavily inspired by Square's Retrofit library, Refit turns your REST API into a live interface.
C#
8,590
star
2

ReactiveUI

An advanced, composable, functional reactive model-view-viewmodel framework for all .NET platforms that is inspired by functional reactive programming. ReactiveUI allows you to abstract mutable state away from your user interfaces, express the idea around a feature in one readable place and improve the testability of your application.
C#
8,080
star
3

Akavache

An asynchronous, persistent key-value store created for writing desktop and mobile applications, based on SQLite3. Akavache is great for both storing important data as well as cached local data that expires.
C#
2,448
star
4

splat

Makes things cross-platform
C#
972
star
5

Camelotia

Cross-platform sample .NET GUI for cloud file management.
C#
556
star
6

ReactiveUI.Samples

This repository contains ReactiveUI samples.
C#
329
star
7

Fusillade

An opinionated HTTP library for Mobile Development
C#
310
star
8

Pharmacist

Builds observables from events.
C#
240
star
9

ReactiveUI.Validation

Validation helpers for ReactiveUI-based apps.
C#
238
star
10

ReactiveMvvm

Cross-platform ReactiveUI sample app built for a talk at MSK .NET conf.
C#
180
star
11

Sextant

A ReactiveUI navigation library for Xamarin.Forms
C#
157
star
12

website

ReactiveUI documentation and guidelines website. PR's welcome! πŸ’–
C#
35
star
13

Splat.DI.SourceGenerator

C#
30
star
14

ReactiveUI.SourceGenerators

Use source generators to generate objects.
C#
27
star
15

Reactive.Wasm

A Web Assembly versions of the System.Reactive classes.
C#
13
star
16

ReactiveObject.Generators

C#
8
star
17

rfcs

RFCs for changes to ReactiveUI
Shell
5
star
18

styleguide

design / marketing style guide for ReactiveUI
HTML
4
star
19

Maui.Plugins.Popup

ReactiveUI support for Maui Popups
C#
4
star
20

.github

2
star
21

actions-common

Common GitHub actions for the ReactiveUI project
2
star
22

ReactiveUI.Uno

C#
1
star