-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cl_abap_weak_reference + osql workaround (#739)
- Loading branch information
Showing
7 changed files
with
151 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
CLASS cl_abap_weak_reference DEFINITION PUBLIC. | ||
PUBLIC SECTION. | ||
METHODS constructor | ||
IMPORTING | ||
oref TYPE REF TO object. | ||
|
||
METHODS get | ||
RETURNING | ||
VALUE(oref) TYPE REF TO object. | ||
PRIVATE SECTION. | ||
DATA mv_ref TYPE x LENGTH 1. | ||
ENDCLASS. | ||
|
||
CLASS cl_abap_weak_reference IMPLEMENTATION. | ||
METHOD constructor. | ||
ASSERT oref IS NOT INITIAL. | ||
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakRef | ||
WRITE '@KERNEL this.mv_ref = new WeakRef(oref);'. | ||
ENDMETHOD. | ||
|
||
METHOD get. | ||
WRITE '@KERNEL oref.set(this.mv_ref.deref());'. | ||
ENDMETHOD. | ||
ENDCLASS. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
CLASS ltcl_dummy DEFINITION FOR TESTING. | ||
ENDCLASS. | ||
|
||
CLASS ltcl_dummy IMPLEMENTATION. | ||
ENDCLASS. | ||
|
||
****************************** | ||
|
||
CLASS ltcl_weak_reference DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT FINAL. | ||
|
||
PRIVATE SECTION. | ||
METHODS basic FOR TESTING. | ||
METHODS collected FOR TESTING. | ||
|
||
METHODS method RETURNING VALUE(weak) TYPE REF TO cl_abap_weak_reference. | ||
|
||
ENDCLASS. | ||
|
||
CLASS ltcl_weak_reference IMPLEMENTATION. | ||
|
||
METHOD basic. | ||
|
||
DATA ref TYPE REF TO ltcl_dummy. | ||
DATA weak TYPE REF TO cl_abap_weak_reference. | ||
|
||
CREATE OBJECT ref. | ||
CREATE OBJECT weak EXPORTING oref = ref. | ||
|
||
cl_abap_unit_assert=>assert_equals( | ||
act = weak->get( ) | ||
exp = ref ). | ||
|
||
ENDMETHOD. | ||
|
||
METHOD method. | ||
DATA ref TYPE REF TO ltcl_dummy. | ||
CREATE OBJECT ref. | ||
CREATE OBJECT weak EXPORTING oref = ref. | ||
ENDMETHOD. | ||
|
||
METHOD collected. | ||
DATA weak TYPE REF TO cl_abap_weak_reference. | ||
|
||
weak = method( ). | ||
|
||
* https://github.com/orgs/nodejs/discussions/36467 | ||
WRITE '@KERNEL await new Promise(resolve => setTimeout(resolve, 0));;'. | ||
* works only on NodeJS, with --expose-gc | ||
WRITE '@KERNEL global.gc();'. | ||
|
||
cl_abap_unit_assert=>assert_initial( weak->get( ) ). | ||
ENDMETHOD. | ||
|
||
ENDCLASS. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters