2015-08-13 23:54:40 +02:00
|
|
|
---
|
|
|
|
layout: pattern
|
|
|
|
title: Half-Sync/Half-Async
|
|
|
|
folder: half-sync-half-async
|
2015-08-15 18:03:05 +02:00
|
|
|
permalink: /patterns/half-sync-half-async/
|
2015-08-20 21:40:07 +02:00
|
|
|
categories: Concurrency
|
2021-05-19 10:49:05 -06:00
|
|
|
language: en
|
2015-12-28 15:52:44 +02:00
|
|
|
tags:
|
2019-12-13 21:09:28 +02:00
|
|
|
- Performance
|
2015-08-13 23:54:40 +02:00
|
|
|
---
|
|
|
|
|
2016-01-03 21:14:30 +01:00
|
|
|
## Intent
|
|
|
|
The Half-Sync/Half-Async pattern decouples synchronous I/O from
|
2015-08-13 23:54:40 +02:00
|
|
|
asynchronous I/O in a system to simplify concurrent programming effort without
|
|
|
|
degrading execution efficiency.
|
|
|
|
|
2019-12-07 20:01:13 +02:00
|
|
|
## Class diagram
|
2015-08-22 13:32:14 +05:30
|
|
|

|
2015-08-13 23:54:40 +02:00
|
|
|
|
2016-01-03 21:14:30 +01:00
|
|
|
## Applicability
|
|
|
|
Use Half-Sync/Half-Async pattern when
|
2015-08-13 23:54:40 +02:00
|
|
|
|
|
|
|
* a system possesses following characteristics:
|
|
|
|
* the system must perform tasks in response to external events that occur asynchronously, like hardware interrupts in OS
|
|
|
|
* it is inefficient to dedicate separate thread of control to perform synchronous I/O for each external source of event
|
|
|
|
* the higher level tasks in the system can be simplified significantly if I/O is performed synchronously.
|
|
|
|
* one or more tasks in a system must run in a single thread of control, while other tasks may benefit from multi-threading.
|
|
|
|
|
2016-01-03 21:14:30 +01:00
|
|
|
## Real world examples
|
2015-08-13 23:54:40 +02:00
|
|
|
|
2019-09-07 23:48:13 +05:30
|
|
|
* [BSD Unix networking subsystem](https://www.dre.vanderbilt.edu/~schmidt/PDF/PLoP-95.pdf)
|
2015-08-13 23:54:40 +02:00
|
|
|
* [Real Time CORBA](http://www.omg.org/news/meetings/workshops/presentations/realtime2001/4-3_Pyarali_thread-pool.pdf)
|
2021-09-28 21:43:31 +03:00
|
|
|
* [Android AsyncTask framework](https://developer.android.com/reference/android/os/AsyncTask)
|
2015-09-03 18:17:07 +05:30
|
|
|
|
2016-01-03 21:14:30 +01:00
|
|
|
## Credits
|
2015-09-03 18:17:07 +05:30
|
|
|
|
2019-09-07 23:48:13 +05:30
|
|
|
* [Douglas C. Schmidt and Charles D. Cranor - Half Sync/Half Async](https://www.dre.vanderbilt.edu/~schmidt/PDF/PLoP-95.pdf)
|
2020-07-06 13:31:07 +03:00
|
|
|
* [Pattern Oriented Software Architecture Volume 2: Patterns for Concurrent and Networked Objects](https://www.amazon.com/gp/product/0471606952/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0471606952&linkCode=as2&tag=javadesignpat-20&linkId=889e4af72dca8261129bf14935e0f8dc)
|