I want to create a simple Tic Tac Toe game that will play between users of an SAP system.
I have a class CL_TTT_MANAGER with a SIGNUP method that assigns players to a game. My class is a memory-enabled class because its goal is to access all users of the juice system.
The registration procedure is performed using a very simple algorithm.
1: The flag "WAITING_FOR_PLAYERS" exists and is set to ABAP_FALSE. originally. 2: When the first player calls "SIGNUP", the flag is set to "ABAP_TRUE". 3: When the second player calls "SIGNUP", the flag is set to "ABAP_FALSE" and a game instance is created.
The problem with my SIGNUP method is that it depends on the state, namely, it must remember the name of the first player, and this is achieved using a private attribute.
For any of you who have worked with concurrency problems, you will find a data race, namely: if immediately after the second player is registered, the third appears, the name of the first player can be replaced with the name of the third.
How to sync these things in abap? What is my mechanism for this? I have not seen anything like this in the documentation (I studied only for 2 months). Should I implement this myself, or is there something that can help me?
source
share