Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

Exchanger.d File Reference

A synchronization point at which two threads can exchange objects. More...

Go to the source code of this file.

Functions

class Exchanger (Value)

Variables

module mango locks Exchanger


Detailed Description

A synchronization point at which two threads can exchange objects.

Written by Doug Lea with assistance from members of JCP JSR-166 Expert Group and released to the domain, as explained at http://creativecommons.org/licenses/publicdomain Ported to D by Ben Hinkle. Email comments and bug reports to ben.hinkle@gmail.com

revision 2.0

Definition in file Exchanger.d.


Function Documentation

class Exchanger Value   )  [private]
 

Holder for the item being exchanged

Arrival count transitions from 0 to 1 to 2 then back to 0 during an exchange.

Main exchange function, handling the different policy variants.

Create a new Exchanger.

Waits for another thread to arrive at this exchange point and then transfers the given object to it, receiving its object in return.

If another thread is already waiting at the exchange point then it is resumed for thread scheduling purposes and receives the object passed in by the current thread. The current thread returns immediately, receiving the object passed to the exchange by that other thread.

If no other thread is already waiting at the exchange then the current thread is disabled for thread scheduling purposes and lies dormant until some other thread enters the exchange.

Parameters:
x the object to exchange
Returns:
the object provided by the other thread.

Waits for another thread to arrive at this exchange point (unless the specified waiting time elapses), and then transfers the given object to it, receiving its object in return.

If another thread is already waiting at the exchange point then it is resumed for thread scheduling purposes and receives the object passed in by the current thread. The current thread returns immediately, receiving the object passed to the exchange by that other thread.

If no other thread is already waiting at the exchange then the current thread is disabled for thread scheduling purposes and lies dormant until one of three things happens:

  • Some other thread enters the exchange; or
  • The specified waiting time elapses.

If the specified waiting time elapses then TimeoutException is thrown. If the time is less than or equal to zero, the method will not wait at all.

Parameters:
x the object to exchange
timeout the maximum time to wait
unit the time unit of the timeout argument.
Returns:
the object provided by the other thread.

Definition at line 66 of file Exchanger.d.

References ReentrantLock, TimeUnit, toNanos(), and x.


Variable Documentation

module mango locks Exchanger
 

Definition at line 14 of file Exchanger.d.


Generated on Fri Nov 11 18:44:25 2005 for Mango by  doxygen 1.4.0