Files
abstract-document
abstract-factory
adapter
aggregator-microservices
api-gateway
async-method-invocation
bridge
builder
business-delegate
caching
callback
chain
command
composite
dao
data-mapper
decorator
delegation
dependency-injection
double-checked-locking
double-dispatch
event-aggregator
event-driven-architecture
execute-around
facade
factory-kit
factory-method
feature-toggle
fluentinterface
flux
flyweight
front-controller
half-sync-half-async
etc
src
README.md
pom.xml
hexagonal
intercepting-filter
interpreter
iterator
layers
lazy-loading
mediator
memento
message-channel
model-view-controller
model-view-presenter
monad
monostate
multiton
mute-idiom
mutex
naked-objects
null-object
object-pool
observer
page-object
poison-pill
private-class-data
producer-consumer
property
prototype
proxy
publish-subscribe
reactor
reader-writer-lock
repository
resource-acquisition-is-initialization
semaphore
servant
service-layer
service-locator
singleton
specification
state
step-builder
strategy
template-method
thread-pool
tolerant-reader
twin
value-object
visitor
.gitignore
.travis.yml
CODE_COVERAGE.md
CONTRIBUTING.MD
LICENSE.md
README.md
checkstyle-suppressions.xml
checkstyle.xml
exclude-pmd.properties
faq.md
pom.xml
update-ghpages.sh
java-design-patterns/half-sync-half-async/README.md

38 lines
1.6 KiB
Markdown
Raw Normal View History

---
layout: pattern
title: Half-Sync/Half-Async
folder: half-sync-half-async
permalink: /patterns/half-sync-half-async/
categories: Concurrency
2015-12-28 15:52:44 +02:00
tags:
- Java
- Difficulty-Intermediate
---
## Intent
The Half-Sync/Half-Async pattern decouples synchronous I/O from
asynchronous I/O in a system to simplify concurrent programming effort without
degrading execution efficiency.
![Half-Sync/Half-Async class diagram](./etc/half-sync-half-async.png)
## Applicability
Use Half-Sync/Half-Async pattern when
* 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.
## Real world examples
* [BSD Unix networking subsystem](http://www.cs.wustl.edu/~schmidt/PDF/PLoP-95.pdf)
* [Real Time CORBA](http://www.omg.org/news/meetings/workshops/presentations/realtime2001/4-3_Pyarali_thread-pool.pdf)
* [Android AsyncTask framework](http://developer.android.com/reference/android/os/AsyncTask.html)
## Credits
* [Douglas C. Schmidt and Charles D. Cranor - Half Sync/Half Async](http://www.cs.wustl.edu/~schmidt/PDF/PLoP-95.pdf)
* [Pattern Oriented Software Architecture Vol I-V](http://www.amazon.com/Pattern-Oriented-Software-Architecture-Volume-Patterns/dp/0471958697)