Ferreteria/v0.6/clade/IO/Aspect/Connx: Difference between revisions
< Ferreteria | v0.6 | clade | IO | Aspect
Jump to navigation
Jump to search
(Created page with "{{page/clade/v2 |fam= {{!}} align=right {{!}} {{l/ver/clade|IO|Aspect}} {{!}} align=Center {{!}} {{l/ver/clade|IO\Aspect|Connx}} {{!}} align=left {{!}} {{l/ver/clade|IO\Aspect\Connx|Plug}} |alia= {{!-!}} '''Base'''* [ca,i,t] {{!!}} {{l/ver/clade/full|p=ferreteria|IO|Aspect}} {{!-!}} '''Action'''* [c,i] {{!!}} → {{l/ver/clade/full|p=ferreteria|Sys\Events|ItWent}} → {{!-!}} '''SelfIface''' {{!!}} {{l/ver/clade/full|p=ferreteria|IO\Aspect|Connx}} }} ==A...") |
No edit summary |
||
| Line 2: | Line 2: | ||
|fam= | |fam= | ||
{{!}} align=right {{!}} {{l/ver/clade|IO|Aspect}} | {{!}} align=right {{!}} {{l/ver/clade|IO|Aspect}} | ||
{{!}} align= | {{!}} align=center {{!}} → {{l/ver/clade|IO\Aspect|Connx}} → | ||
{{!}} align=left {{!}} {{l/ver/clade|IO\Aspect\Connx|Plug}} | {{!}} align=left {{!}} {{l/ver/clade|IO\Aspect\Connx|Plug}} | ||
|alia= | |alia= | ||
{{!-!}} '''Base'''* [ca,i,t] {{!!}} {{l/ver/clade/full|p=ferreteria|IO|Aspect}} | {{!-!}} '''Base'''* [ca,i,t] {{!!}} {{l/ver/clade/full|p=ferreteria|IO|Aspect}} | ||
{{!-!}} '''Action'''* [c,i] {{!!}} | {{!-!}} '''Action'''* [c,i] {{!!}} {{l/ver/clade/full|p=ferreteria|Sys\Events|ItWent}} | ||
{{!-!}} '''SelfIface''' {{!!}} {{l/ver/clade/full|p=ferreteria|IO\Aspect|Connx}} | {{!-!}} '''SelfIface''' {{!!}} {{l/ver/clade/full|p=ferreteria|IO\Aspect|Connx}} | ||
Revision as of 00:56, 23 October 2025
| ||||||||||||||||||
About
- PURPOSE: encapsulates a connection to a Socket (...I think...)
- SERVICES:
- keeps track of how many requests there are for a thing to be open
- internally requests the actual opening and closing as needed (when req-qty changes to/from zero)
History
- 2024-11-28 extracted relevant code from ssh/Shell so that Buffer and fsys/Node could use it too.
- 2025-03-28 moved from [WFe]IO\Connx\Aux\xOpener -> [WFe]IO\xConnx; added Base clade, caConnx
- 2025-05-27 moved from [WFe]IO -> [WFe]IO\Aspect; correspondingly re-parented
Code
as of 2025-10-22
interface iConnx extends BaseIface {
// LIFECYCLE
function IsOpen() : bool;
function Open() : ActionIface;
function Shut() : ActionIface;
}
trait tConnx {
use BaseTrait;
abstract protected function ActualOpen() : ActionIface;
abstract protected function ActualShut() : ActionIface;
private int $nOpens = 0;
public function IsOpen() : bool { return $this->nOpens > 0; }
private $oAct; // 2025-04-12 For now, this only saves the status of the ActualOpen() operation, not ActualShut().
public function ItWent() : ActionIface { return $this->oAct; }
public function Open() : ActionIface {
$nOpens = $this->nOpens++;
#echo get_called_class()." OPENS: [$nOpens]".CRLF;
if ($nOpens === 0) {
#echo ' - actual open:'.CRLF;
$oAct = $this->ActualOpen();
$this->oAct = $oAct;
#echo ' - - $oAct class: '.get_class($oAct).CRLF;
} else {
#echo ' - opening existing $oAct'.CRLF;
// Report results of actual open, which happened earlier.
$oAct = $this->oAct;
}
return $oAct;
}
public function Shut() : ActionIface {
$nOpens = --$this->nOpens;
if ($nOpens == 0) {
$oAct = $this->ActualShut();
} else {
$oAct = new ActionClass;
$oAct->SetNoOp();
// Only the final/real Shut() actually does anything.
}
return $oAct;
}
}
abstract class caConnx extends BaseClass implements SelfIface {
use tConnx;
}