並び順

ブックマーク数

期間指定

  • から
  • まで

1 - 38 件 / 38件

新着順 人気順

asyncの検索結果1 - 38 件 / 38件

  • JavaScript で then を使うのは避けよう(await / async の初級者まとめ)

    JavaScript において、特に苦手とする人が多い印象のある Promise ですが、await と async の文法が導入されたことで、Promise の仕様を深く理解しなくても非同期処理を自然に書けるようになってきたのではないかと思います。 極論ですが、JavaScript の非同期処理は async await new Promise のみで、(ほぼ)全て表現可能です。特別な理由がない限り then を使わないようにしましょう、ということを周知するのがこの記事の目的です。 なお本記事では Promise の rejected の状態についてほとんど解説しておりません。基本を理解したら、別記事でぜひ学んでみてください。 Promise とは? Promise は、少し乱暴に説明すると「実行が終わっていないかもしれない何らかの関数」を包んだオブジェクトです。 普通の関数とは違って、

    • async/awaitにおけるエラー処理を実行の順番から整理する - Qiita

      はじめに promiseを使うとき、いつもpromiseメソッドチェーンで記載していますか? async/awaitを利用していますか? もちろん状況によって両方書くのが殆どだとは思うのですが、私はasync/awaitの方が同期的な書き方ゆえに読みやすいため、なるべくそちらで記載しています。しかしながら、エラーハンドリングが理解できていなかったため、エラーの所在を突き止めるのに苦労してしまいました。 そのため、これを機にasync/awaitにおけるエラーハンドリングについて備忘録的にまとめておきます。 この記事のまとめ; catchされるエラーはrejectのみか、throwされたエラーも含まれるか →両方catchできる async関数における処理の順序、awaitがある場合とない場合 →awaitがない場合には同期的に処理が実行され、catchできなくなる エラー処理を外側に伝播し

        async/awaitにおけるエラー処理を実行の順番から整理する - Qiita
      • decoding="async" について詳しく調べてみる

        この記事は2023年7月19日時点の Chrome の最新版 115.0.5790.98 を使って検証しました。今後 Chrome の実装によって挙動が変わる可能性はございます。 はじめに 画像表示のパフォーマンス改善において、「decoding="async" をつけましょう」というのをよく見かけますが、おそらくほとんどの人がその実際の挙動を理解していない、あるいは誤った認識をしていると思います。今回詳しく調べる前の僕も含めて。 loading と decoding の違い 画像のパフォーマンス改善で decoding="async" のほかに、もう一つよく言及されるのが loading="lazy" です。decoding 属性について詳しく見る前に、まずは loading 属性との違いについて理解したほうがいいと思います。 loading とは、ブラウザがどのように画像を読み込むかを

          decoding="async" について詳しく調べてみる
        • async/await 比較(C#, JavaScript, Python) - Qiita

          using System.Windows.Threading; Dispatcher.CurrentDispatcher.InvokeAsync(async () => { // いろいろな処理... // メッセージループを終了させる Dispatcher.CurrentDispatcher.BeginInvokeShutdown(DispatcherPriority.Normal); }); Dispatcher.Run(); WPF とか WinForms とかでは、フレームワークがすでにメッセージループを回しているので、自分で Dispatcher.Run() する必要はない。 JavaScript 自分で書く必要なし。 Python asyncio.run(最初に実行するasync関数)

            async/await 比較(C#, JavaScript, Python) - Qiita
          • 【C#】非同期処理とasync/await - Annulus Games

            今回の記事はasync/awaitについて。 C#に限らず、現在では多くのプログラミング言語が非同期処理を扱う言語機能としてasync/awaitを採用しています。現在の.NETでも至る所にasync/awaitが使われており、避けて通ることはできない重要な機能となっています。 そこで今回は、C#における非同期処理とasync/await、またC#8.0で導入された非同期ストリームとIAsyncEnumerable<T>について、基本的な使い方を解説していきます。 また、記事の後半では実際にasync/awaitがどのように動作しているかをコンパイル結果を通して説明していきます。この辺りはやや高度なトピックになるため読み飛ばしていただいても構いませんが、async/awaitをより深く理解したい方は是非そちらも読んでみてください。 同期処理 / 非同期処理 async/awaitに関する話

              【C#】非同期処理とasync/await - Annulus Games
            • Why choose async/await over threads?

              A common refrain is that threads can do everything that async/await can, but simpler. So why would anyone choose async/await? This is a common question that I’ve seen a lot in the Rust community. Frankly, I completely understand where it’s coming from. Rust is a low-level language that doesn’t hide the complexity of coroutines from you. This is in opposition to languages like Go, where async happe

                Why choose async/await over threads?
              • Async Rust Is A Bad Language

                But to get at whatever the hell I mean by that, we need to talk about why async Rust exists in the first place. Let’s talk about: Modern Concurrency: They’re Green, They’re Mean, & They Ate My Machine Suppose we want our code to go fast. We have two big problems to solve: We want to use the whole computer. Code runs on CPUs, and in 2023, even my phone has eight of the damn things. If I want to use

                  Async Rust Is A Bad Language
                • async/awaitは今後もベストフレンドであり続けるか - hadashiA

                  えーあーー みなさん聞こえますでしょうか。この記事はC# アドベントカレンダー17日めのために書かれました。 いくつかみかけた、async/await と java loom/goroutine的なものを比較する議論に興味があり、少し追ってみた感想です。実装まで深く調べられてません。 TL;DR Green Thread Experiment Results #2398 .NET の runtimelabにて、async/awaitの代替としてのグリーンスレッドを検証した結果が公開されていたが、今後も async/await でいくという結論になっている。 JVM (Java) は対象的に、コードの書き方をなにも変えなくてもランタイムが自動的にI/Oを非同期にしてくれる夢のVirtual Thread を導入した。 Rust界隈では「Why async/await ? why? why?

                    async/awaitは今後もベストフレンドであり続けるか - hadashiA
                  • Learning Async Rust With Entirely Too Many Web Servers

                    I've found that one of the best ways to understand a new concept is to start from the very beginning. Start from a place where it doesn't exist yet and recreate it yourself, learning in the process not just how it works, but why it was designed the way it was. This isn't a practical guide to async, but hopefully some of the background knowledge it covers will help you think about asynchronous prob

                      Learning Async Rust With Entirely Too Many Web Servers
                    • GitHub - sxyazi/yazi: 💥 Blazing fast terminal file manager written in Rust, based on async I/O.

                      Yazi (means "duck") is a terminal file manager written in Rust, based on non-blocking async I/O. It aims to provide an efficient, user-friendly, and customizable file management experience. 💡 A new article explaining its internal workings: Why is Yazi Fast? 🚀 Full Asynchronous Support: All I/O operations are asynchronous, CPU tasks are spread across multiple threads, making the most of available

                        GitHub - sxyazi/yazi: 💥 Blazing fast terminal file manager written in Rust, based on async I/O.
                      • Task/ValueTask を直接返せる場合でも原則非同期メソッド (async/await) にしたほうが良い

                        ユーザーコードでは Task/ValueTask (ジェネリック版含む) を直接返すことが可能の場合でも原則として非同期メソッドにして await することをおすすめします。 原則として、というのはこの記事で紹介するようなポイントを理解した上で最適化のために行うのは良いのですが、ユーザーコードでは落とし穴にハマるのを避けるためにほとんどのケースで素直に非同期メソッドにした方がよい、という話です。 Task/ValueTask を直接返す、返さないとは そもそも Task/ValueTask をそのまま返すコードというのはどういうものかというと、次のようなコードです。 public async Task Main() => await NantokaAsync(); public ValueTask NantokaAsync() { // 非同期を必要としない WriteAsync を呼び出

                          Task/ValueTask を直接返せる場合でも原則非同期メソッド (async/await) にしたほうが良い
                        • Rails 7.1: Dockerfiles, BYO Authentication, More Async Queries, and more!

                          Rails 7.1: Dockerfiles, BYO Authentication, More Async Queries, and more! Rails World just started and we are getting together with the community in person to celebrate of the 20th anniversary of Rails and the release of Rails 7.1. In this release there has been over five thousand commits made by over 800 contributors since Rails 7.0, so it is packed with new features and improvements. Dockerfiles

                            Rails 7.1: Dockerfiles, BYO Authentication, More Async Queries, and more!
                          • Rails 7.1 Beta 1: Dockerfiles, BYO Authentication, More Async Queries, and more!

                            Rails 7.1 Beta 1: Dockerfiles, BYO Authentication, More Async Queries, and more! Rails World is fast approaching and we’re gearing up to celebrate the 20th anniversary of Rails in style with the first beta release of Rails 7.1! There has been over five thousand commits made by over 800 contributors since Rails 7.0, so this release is packed with new features and improvements. Please help us test a

                              Rails 7.1 Beta 1: Dockerfiles, BYO Authentication, More Async Queries, and more!
                            • Announcing `async fn` and return-position `impl Trait` in traits | Rust Blog

                              Announcing `async fn` and return-position `impl Trait` in traits The Rust Async Working Group is excited to announce major progress towards our goal of enabling the use of async fn in traits. Rust 1.75, which hits stable next week, will include support for both -> impl Trait notation and async fn in traits. This is a big milestone, and we know many users will be itching to try these out in their o

                                Announcing `async fn` and return-position `impl Trait` in traits | Rust Blog
                              • SpringBootでAsyncを使う時に知っておきたいExecutorのこと - 日々常々

                                SpringFramework 6.0.11 SpringBoot 3.1.2 @Async と @EnableAsync の使い方 SpringFrameworkで @Async を使うとかんたんにメソッドを非同期で実行できます。 @Component class AsyncComponent { @Async void method() { // 時間のかかる処理 } } 使う側は単にメソッドを呼び出すだけです。戻り値を処理したいなら Future で受ければいいけど、投げっばでいいなら void で良い。投げっばでいい場合の方が多いはず。 @Async を使うためにはアノテーションを処理する何かしらが必要で、この一式を用意するように指示するのが @EnableAsync です。 以下のようなクラスをSpringがわかるところに置いてあげます。 @EnableAsync @Config

                                  SpringBootでAsyncを使う時に知っておきたいExecutorのこと - 日々常々
                                • The State of Async Rust: Runtimes | corrode Rust Consulting

                                  Recently, I found myself returning to a compelling series of blog posts titled Zero-cost futures in Rust by Aaron Turon about what would become the foundation of Rust's async ecosystem and the Tokio runtime. This series stands as a cornerstone in writings about Rust. People like Aaron are the reason why I wanted to be part of the Rust community in the first place. While 2016 evokes nostalgic memor

                                    The State of Async Rust: Runtimes | corrode Rust Consulting
                                  • Async Ruby on Rails

                                    Async programming can make your apps faster. I’ll share how you can use async in Ruby on Rails to speed up your app. While there are examples in Ruby, the principles apply to any language. I’ll group the examples into two basic principles. Here’s the first one: Don’t do now what you can do later Delay doing stuff as much as possible. Being lazy is not necessarily a bad thing. In practice, that mea

                                    • Why async Rust?

                                      Async/await syntax in Rust was initially released to much fanfare and excitement. To quote Hacker News at the time: This is going to open the flood gates. I am sure lot of people were just waiting for this moment for Rust adoption. I for one was definitely in this boat. Also, this has all the goodness: open-source, high quality engineering, design in open, large contributors to a complex piece of

                                      • Async Rust in a Nutshell

                                        Computers are just as fast as they can be. One way to speed up our programs is to do things in parallel, or concurrently. There is a fine distinction between those two terms. Parallel execution means that we execute two different tasks at the same time, on two different CPUs. Concurrent execution means that a single CPU makes progress on more than one task at the same time, by interleaving the exe

                                          Async Rust in a Nutshell
                                        • asyncを使わずに並行処理をやる方法はないのか - yhara.jp

                                          メモです。 What Color is Your Function? – journal.stuffwithstuff.com async/awaitを実装した言語では、asyncな関数とそうでない関数が区別される つまり、async funcを受け取るメソッドにnormal funcを渡すことはできない(逆もしかり) そのために、.mapと.mapAsyncみたいに各APIにasync版と非async版が必要になる https://blog.yoshuawuyts.com/announcing-the-keyword-generics-initiative/ keyword genericsという案 なぜasyncな関数と普通の関数は互換性がないのか async funcはステートマシンにコンパイルされるから (いやまあ別にそういう決まりはないけど、JS/Rust/C#はいずれもそうして

                                          • Internals of async / await in JavaScript | Akash Hamirwasia

                                            Internals of async / await in JavaScriptJuly 2, 2023 •11 min read If you have ever used JavaScript in the past, there is a high chance you have encountered the async / await syntax. async / await makes it easy to define asynchronous logic in a synchronous way that our brains can comprehend better. Some of you JavaScript veterans might know that async / await is merely a syntactic sugar over the ex

                                              Internals of async / await in JavaScript | Akash Hamirwasia
                                            • How to think about `async`/`await` in Rust - Cliffle

                                              2023-06-30 async fn is an inversion of control Hand-rolling an explicit state machine Explicit state machines mean your caller has control Writing state machines with async fn await is a composition operator Summary (This is a section of the lilos intro guide that people seemed to like, so to increase its visibility, I’m lifting it up into its own post and expanding it a bit. I hope this is a usef

                                              • Hideyuki Tanaka on X: "https://t.co/C8laA40N09 スレッドはasync/awaitよりも単純だし、async/awaitでできることはスレッドでもできるのに、なんでわざわざ複雑なものを選ぶ必要があるのか?というRustコニュニティーでもよく見かける質問に対するわかりやすい解説記事"

                                                • A four year plan for async Rust - Without boats, dreams dry up

                                                  Four years ago today, the Rust async/await feature was released in version 1.39.0. The announcement post says that “this work has been a long time in development – the key ideas for zero-cost futures, for example, were first proposed by Aaron Turon and Alex Crichton in 2016”. It’s now been longer since the release of async/await than the time between the first design work that underlies async/awai

                                                  • [JavaScript] forEachでasync/awaitは使える

                                                    JavaScript の forEach で async/await は使える JavaScrript の forEach で async/await が使えないという誤解が一部あるようですが、全く問題なく使えます。そういう誤解が何故発生してしまうかと言えば、非同期を同期させるための管理を行っていないからです。プログラムは思った通りではなく書いたとおりに動きます。同期させるようにプログラムを書かなければ、その通りの結果が返ってきます。使えないのではなく使っていないのが原因です。 forEach で非同期を同期させるプログラムを作る 配列の内容を 1 秒ごとに一つ表示させるプログラムを forEach で作ってみます。 こちらに実行環境を用意しました プログラム内容 // 疑似セマフォによるスケジューラ const semaphore = ( limit = 1, count = 0, rs

                                                      [JavaScript] forEachでasync/awaitは使える
                                                    • 【2024最新版】traitにasync fnを含める方法

                                                      公約[1]通り、2023年内で async fn in trait が stable Rust (1.75.0) にやってきました。 (本当にめでたい。本当にありがとうございます。) この記事では async fn in trait は何が嬉しいのかを書きます。 ついでにモックについての話もします。 これまでの async trait これまで trait 内で async fn を定義すると、以下のように async-trait crate を使う必要がありました。 言語側に async fn を trait 内に書く仕組みがないので、Box<dyn Future>を返すような関数に変換されていました。 これからの async trait これからは async fn を trait 内で定義できるようになりました。 async trait は、おそらく正式名称ではなく、"async f

                                                        【2024最新版】traitにasync fnを含める方法
                                                      • n8s.site | Async Rust Isn't Bad: You Are

                                                        There have been quite a few articles in the past year or so about the downsides of using Rust and introducing the async keyword into your code base: Why asynchronous Rust doesn't work Mixing Sync and Async Rust Async Rust Is A Bad Language Avoid Async Rust at All Cost ...too lazy to continue searching, but you get the idea It generally boils down to two things: async is invasive. The path of least

                                                          n8s.site | Async Rust Isn't Bad: You Are
                                                        • 【JavaScript】async/awaitとaxios、非同期通信について - Qiita

                                                          axiosとは HTTP通信(データの更新・取得)など、HTTPリクエストのやり取りを簡単に行うことができる、JavaScriptのライブラリです。Node.jsで記述されています。APIを提供するクラウドサービスに対して、データを送受信することができます。 非同期にHTTPメソッド(GET・POST・PUT・DELETE通信など)を取り扱えます。 非同期処理とは 時間の掛かる処理の結果を待たずにすぐ次の処理を実行できる仕組みです。Promiseを使うと簡単に実現できます。 Promiseとは、非同期処理の状態を監視するためのオブジェクトで、非同期処理を同期処理のように扱える書き方です。 使う場面 JSONデータを提供しているAPIと接続して、データを取得することが多いです。 Webの場合、サーバーの中で外部にデータを提供している機能(またはそnページ)のことをAPIとよびます。 asyn

                                                            【JavaScript】async/awaitとaxios、非同期通信について - Qiita
                                                          • </> htmx ~ Examples ~ Async Authentication

                                                            This example shows how to implement an an async auth token flow for htmx. The technique we will use here will take advantage of the fact that you can delay requests using the htmx:confirm event. We first have a button that should not issue a request until an auth token has been retrieved: <button hx-post="/example" hx-target="next output"> An htmx-Powered button </button> <output> -- </output> Nex

                                                            • Unlocking Performance: A Guide to Async Support in Django

                                                              Performance optimization is a crucial aspect of building web applications, and developers are constantly seeking ways to make their applications faster and more responsive. In the world of Django, async support has emerged as a powerful tool for unlocking performance improvements. By embracing async programming, developers can take advantage of non-blocking operations, improved scalability, and en

                                                                Unlocking Performance: A Guide to Async Support in Django
                                                              • 坂本龍一 追悼連載vol.14:デイヴィッド・トゥープとの共演盤がつなぐ、YMO以前と『async』以降 | CINRA

                                                                坂本龍一が発表した数々の音楽作品を紐解く連載「追悼・坂本龍一:わたしたちが聴いた音楽とその時代」(記事一覧はこちら)。 第14回の書き手は、編著『AA 五十年後のアルバート・アイラー』(2021年、カンパニー社)を手がけたライター/音楽批評家の細田成嗣。「即興演奏における発見の歓び」をテーマに、坂本龍一とデイヴィッド・トゥープの共演盤『Garden of Shadows and Light』(2021年)を取り上げる。 本作を1975年に録音された土取利行とのデュオ作『ディスアポイントメント - ハテルマ』と並べることで、坂本龍一のYellow Magic Orchestra以前と『async』(2017年)以降をつなぐものが見えてきた。

                                                                  坂本龍一 追悼連載vol.14:デイヴィッド・トゥープとの共演盤がつなぐ、YMO以前と『async』以降 | CINRA
                                                                • GitHub - danog/php-tokio: Use any async Rust library from PHP!

                                                                  You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert

                                                                    GitHub - danog/php-tokio: Use any async Rust library from PHP!
                                                                  • 「EmEditor」v23.1が公開 ~LSPを用いて入力候補を一覧する機能を追加/マクロで生成AIサービスなどとの連携に役立つ非同期(async)関数も利用可能に

                                                                      「EmEditor」v23.1が公開 ~LSPを用いて入力候補を一覧する機能を追加/マクロで生成AIサービスなどとの連携に役立つ非同期(async)関数も利用可能に
                                                                    • 短時間のミーティングとメールの代替を目指して——NYCの連続起業家が作るAIソフトウェア「Async」 - BRIDGE(ブリッジ)テクノロジー&スタートアップ情報

                                                                      Async のデモ Image credit: Async ボイスメッセージは、私たちの脳にとって最も自然なコミュニケーション方法だ。 Abehassera 氏は、ボイスメッセージングツール「Async」を開発した。Async は、Gmail や Outlook の音声対応版のようなもので、すべてが音声で配信され、ユーザは自分のボイスメールアドレスを持つことができる。Abehassera 氏は、これが短時間の会議に取って代わり、労働者がより効率的な方法で議論できるようになることを期待している。 もう会議の時間を気にしなくていい Async の共同設立者兼 CEO Ilan Abehassera 氏 リモートミーティングは日常茶飯事だが、Abehassera 氏はその一部を WhatsApp を使ったボイスメッセージに置き換えることに慣れてきた。 Abehassera 氏は、ボイスメッセージ

                                                                        短時間のミーティングとメールの代替を目指して——NYCの連続起業家が作るAIソフトウェア「Async」 - BRIDGE(ブリッジ)テクノロジー&スタートアップ情報
                                                                      • How async/await works internally in Swift

                                                                        async/await in Swift was introduced with iOS 15, and I would guess that at this point you probably already know how to use it. But have you ever wondered how async/await works internally? Or maybe why it looks and behaves the way it does, or even why was it even introduced in the first place? In typical SwiftRocks fashion, we're going deep into the Swift compiler to answer these and other question

                                                                          How async/await works internally in Swift
                                                                        • Explaining the internals of async-task from the ground up

                                                                          async-task is one of the most complicated crates in the smol ecosystem. But, fundamentally, it’s just a future on the heap. I pride myself on smol packages being very easy to parse for anyone with a beginner’s level of experience in Rust. By that I mean, if you want to know how smol works, it should be very easy to pick up the source code, read through it, and understand how each individual part w

                                                                            Explaining the internals of async-task from the ground up
                                                                          • 【ChatGPT】と話して学ぶ、【asyncとawait】 - Qiita

                                                                            本記事を書くきっかけ 実務に入る前に、Webアプリケーション開発の基礎の勉強をさせていただいたので、その知見の共有として。特に今回はChatGPTとの対話を通して、"文量多めの読み物っぽい"記事を目指しています。箇条書きより一連の文章の方が好みの方におすすめ。 asyncとawaitについて 「非同期処理」「待機する」といったキーワードはなんとなく覚えていたものの、説明ができなかった「async」と「await」。FEだったら避けては通れないよ!と先輩社員からもお声をいただきましたざっくり言うと asyncで非同期的な処理をして、awaitでその中で待機しなければならない内容を書いている そうです。実際に使うと、asyncの中のawaitがついている部分は完了までその後の処理が止まっているのがわかります。 ではここで早速、ChatGPTに 「サンプルコードで説明して」 とお願いしてみます。

                                                                              【ChatGPT】と話して学ぶ、【asyncとawait】 - Qiita
                                                                            • async対応版Rocket、v0.5を試してみる - paild tech blog

                                                                              Rocketの特徴 Rocketにはこれまで何が起きていたのか v0.5を使う 今回作るアプリケーションのお題 使用するクレートの追加 Routing JSON Fairings: データベース接続 1. コネクションプールを保持するための構造体を用意する 2. 設定ファイルに情報を書く 3. 1で作った構造体をサーバーにattachし、アプリケーションを起動する。 Todoを作成するRoutingを用意する Responder: エラーハンドリング 注意したいこと まとめ 参考サイト お手伝いの @helloyuki です。 最近、asyncに完全対応したRocketがついにリリースされ、v0.5から使えるようになったというニュースが舞い込んできました。RocketはRustのエコシステムをかなり前から支えてきたクレートではあったものの、いくつかの事情によりしばらくなかなか技術選定されな

                                                                                async対応版Rocket、v0.5を試してみる - paild tech blog
                                                                              1