Software design pattern – Wikipedia

Name Description In POSA2[21] Other Active Object Decouples method execution from method invocation that reside in their own thread of control. The goal is to introduce concurrency, by using asynchronous method invocation and a scheduler for handling requests. Yes N/A Balking Only execute an action on an object when the object is in a particular state. No N/A Binding properties Combining multiple observers to force properties in different objects to be synchronized or coordinated in some way.[22] No N/A Compute kernel The same calculation many times in parallel, differing by integer parameters used with non-branching pointer math into shared arrays, such as GPU-optimized Matrix multiplication or Convolutional neural network. No N/A Double-checked locking Reduce the overhead of acquiring a lock by first testing the locking criterion (the ‘lock hint’) in an unsafe manner; only if that succeeds does the actual locking logic proceed.

Can be unsafe when implemented in some language/hardware combinations. It can therefore sometimes be considered an anti-pattern.

Yes N/A Event-based asynchronous Addresses problems with the asynchronous pattern that occur in multithreaded programs.[23] No N/A Guarded suspension Manages operations that require both a lock to be acquired and a precondition to be satisfied before the operation can be executed. No N/A Join Join-pattern provides a way to write concurrent, parallel and distributed programs by message passing. Compared to the use of threads and locks, this is a high-level programming model. No N/A Lock One thread puts a “lock” on a resource, preventing other threads from accessing or modifying it.[24] No PoEAA[15] Messaging design pattern (MDP) Allows the interchange of information (i.e. messages) between components and applications. No N/A Monitor object An object whose methods are subject to mutual exclusion, thus preventing multiple objects from erroneously trying to use it at the same time. Yes N/A Reactor A reactor object provides an asynchronous interface to resources that must be handled synchronously. Yes N/A Read-write lock Allows concurrent read access to an object, but requires exclusive access for write operations. An underlying semaphore might be used for writing, and a Copy-on-write mechanism may or may not be used. No N/A Scheduler Explicitly control when threads may execute single-threaded code. No N/A Thread pool A number of threads are created to perform a number of tasks, which are usually organized in a queue. Typically, there are many more tasks than threads. Can be considered a special case of the object pool pattern. No N/A Thread-specific storage Static or “global” memory local to a thread. Yes N/A Safe Concurrency with Exclusive Ownership Avoiding the need for runtime concurrent mechanisms, because exclusive ownership can be proven. This is a notable capability of the Rust language, but compile-time checking isn’t the only means, a programmer will often manually design such patterns into code – omitting the use of locking mechanism because the programmer assesses that a given variable is never going to be concurrently accessed. No N/A CPU atomic operation x86 and other CPU architectures support a range of atomic instructions that guarantee memory safety for modifying and accessing primitive values (integers). For example, two threads may both increment a counter safely. These capabilities can also be used to implement the mechanisms for other concurrency patterns as above. The C# language uses the Interlocked class for these capabilities. No N/A

Source: https://wikifin.net
Category: Blog

Leave a Comment

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *