Class Switch
An atomic switch that can be either on or off
Inherited Members
Namespace: Akka.Util
Assembly: Akka.dll
Syntax
public class Switch
Constructors
| Improve this Doc View SourceSwitch(Boolean)
TBD
Declaration
public Switch(bool startAsOn = false)
Parameters
Type | Name | Description |
---|---|---|
Boolean | startAsOn | TBD |
Properties
| Improve this Doc View SourceIsOff
Gets a value indicating whether this switch is off. No locking.
Declaration
public bool IsOff { get; }
Property Value
Type | Description |
---|---|
Boolean |
|
IsOn
Gets a value indicating whether this switch is on. No locking.
Declaration
public bool IsOn { get; }
Property Value
Type | Description |
---|---|
Boolean |
|
Methods
| Improve this Doc View SourceIfOff(Action)
Executes the provided action and returns if the action was executed or not, if the switch is IMMEDIATELY off (i.e. no lock involved)
Declaration
public bool IfOff(Action action)
Parameters
Type | Name | Description |
---|---|---|
Action | action | The action. |
Returns
Type | Description |
---|---|
Boolean | Return |
IfOn(Action)
Executes the provided action and returns if the action was executed or not, if the switch is IMMEDIATELY on (i.e. no lock involved)
Declaration
public bool IfOn(Action action)
Parameters
Type | Name | Description |
---|---|---|
Action | action | The action. |
Returns
Type | Description |
---|---|
Boolean | Return |
Locked(Action)
TBD
Declaration
public void Locked(Action action)
Parameters
Type | Name | Description |
---|---|---|
Action | action | TBD |
SwitchOff()
Switches the switch off (if on). Uses locking.
Declaration
public bool SwitchOff()
Returns
Type | Description |
---|---|
Boolean | Returns |
SwitchOff(Action)
Executes the provided action if the lock is on. This is done under a lock so be very careful with longrunning/blocking operations in it. Only executes the action if the switch is on, and switches it off immediately after obtaining the lock. Will switch it back on if the provided action throws an exception.
Declaration
public bool SwitchOff(Action action)
Parameters
Type | Name | Description |
---|---|---|
Action | action | TBD |
Returns
Type | Description |
---|---|
Boolean | Returns |
SwitchOn()
Switches the switch on (if off). Uses locking.
Declaration
public bool SwitchOn()
Returns
Type | Description |
---|---|
Boolean | Returns |
SwitchOn(Action)
Executes the provided action if the lock is off. This is done under a lock so be very careful with longrunning/blocking operations in it. Only executes the action if the switch is off, and switches it on immediately after obtaining the lock. Will switch it back off if the provided action throws an exception.
Declaration
public bool SwitchOn(Action action)
Parameters
Type | Name | Description |
---|---|---|
Action | action | TBD |
Returns
Type | Description |
---|---|
Boolean | Returns |
TranscendFrom(Boolean, Action)
TBD
Declaration
protected bool TranscendFrom(bool from, Action action)
Parameters
Type | Name | Description |
---|---|---|
Boolean | from | TBD |
Action | action | TBD |
Returns
Type | Description |
---|---|
Boolean | TBD |
WhileOff(Action)
Executes the provided action and returns if the action was executed or not, if the switch is off, waiting for any pending changes to happen before (locking) Be careful of longrunning or blocking within the provided action as it can lead to deadlocks or bad performance
Declaration
public bool WhileOff(Action action)
Parameters
Type | Name | Description |
---|---|---|
Action | action | TBD |
Returns
Type | Description |
---|---|
Boolean | TBD |
WhileOn(Action)
Executes the provided action and returns if the action was executed or not, if the switch is on, waiting for any pending changes to happen before (locking) Be careful of longrunning or blocking within the provided action as it can lead to deadlocks or bad performance
Declaration
public bool WhileOn(Action action)
Parameters
Type | Name | Description |
---|---|---|
Action | action | TBD |
Returns
Type | Description |
---|---|
Boolean | TBD |