This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Concurrent; | |
| using System.Threading; | |
| using System.Threading.Tasks; | |
| using System.Threading.Tasks.Dataflow; | |
| namespace TDFDemo | |
| { | |
| class Program | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @FunctionalInterface | |
| public interface PipelineStep<I, O, Ctx> { | |
| static <I, O, Ctx> PipelineStep<I, O, Ctx> of(PipelineStep<I, O, Ctx> source) { | |
| return source; | |
| } | |
| O execute(I value, Ctx context) throws Exception; | |
| default <R> PipelineStep<I, R, Ctx> pipe(PipelineStep<O, R, Ctx> next) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class MyTask : ScheduleTask | |
| { | |
| public MyTask(IServiceScopeFactory serviceScopeFactory) : base(serviceScopeFactory) | |
| { | |
| } | |
| protected override string CronExpression => "*/10 * * * *"; | |
| public override Task Execute(IServiceProvider serviceProvider) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/zsh | |
| for i in */.git; | |
| do ( echo $i; cd $i/..; git pull; git fetch -p && for branch in `git branch -vv | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done ); | |
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| suspend fun someSuspendableOperation(): String { | |
| delay(1000L) // representation of IO operation like going to DB | |
| return "hello" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| suspend fun doOperation1() { | |
| delay(1000L) | |
| } | |
| suspend fun getSomeResult(): String { | |
| delay(2000L) | |
| return "hello" | |
| } | |
| fun main(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun main() { | |
| runBlocking { | |
| val deferred1 = async { operation1() } | |
| val deferred2 = async { operation2() } | |
| println("[${(SimpleDateFormat("hh:mm:ss")).format(Date())}] Awaiting computations...") | |
| val result = deferred1.await() + deferred2.await() | |
| println("[${(SimpleDateFormat("hh:mm:ss")).format(Date())}] The result is $result") | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun main() { | |
| runBlocking { | |
| val deferred1 = async { operation1() } | |
| val deferred2 = async { operation2() } | |
| println("[${(SimpleDateFormat("hh:mm:ss")).format(Date())}] Awaiting computations...") | |
| val result = deferred1.await() + deferred2.await() | |
| println("[${(SimpleDateFormat("hh:mm:ss")).format(Date())}] The result is $result") | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun main() = runBlocking { | |
| GlobalScope.launch { | |
| delay(1000L) | |
| print("World!") | |
| } | |
| print("Hello") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun concurrencyTest(){ | |
| val time1 = measureTimeMillis { | |
| runBlocking { | |
| val listOfDeferred: List<Deferred<Int>> = (1..50).map { i -> | |
| async { | |
| delay(100) | |
| Int.MIN_VALUE | |
| } | |
| } | |
| } |
OlderNewer