hust-diangroup / ns3-ai

Enable the interaction between ns-3 and popular frameworks using Python, which mean you can train and test your AI algorithms in ns-3 without changing any frameworks you are using now!
GNU General Public License v2.0
220 stars 80 forks source link

Option to release shared memory on python side with rollback #78

Open Flunzmas opened 1 year ago

Flunzmas commented 1 year ago

Hey there,

in the file py_interface.py, both Ns3AIDL and Ns3AIRL define ReleaseAndRollback(). From my understanding, this enables unlocking the memory without yielding control to the other side (useful for sequential read accesses on the python side, just like you could use GetCompleted() on the C++ side for a release with rollback). However, the __exit__() method of these two classes uses Release() only.

Would it make sense to extend the context manager implementation by allowing to release with rollback, e.g. to enable sequential read accesses on the same side? So far I have implemented a simple workaround via a method SetRollbackOnRelease() on my local branch (see here).