I want to create a simple Tic Tac Toe game, to be played between users of a SAP system.
I have a CL_TTT_MANAGER class with a SIGNUP method that assigns players to a game. My class is a shared-memory enabled class, because it's purpose is to potentially be accessed by all the users of a sap system.
The signup procedure is done using a very simple algorithm.
1:A "WAITING_FOR_PLAYERS" flag exists, and is set to ABAP_FALSE. initially. 2:When a first player calls "SIGNUP", the flag is set to "ABAP_TRUE". 3:When a second player calls "SIGNUP", the flag is set to "ABAP_FALSE" and the game instance is created.
The problem with my SIGNUP method is that it relies on state, namely it has to 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 spot a data race, namely that if right after the second player signs up, a third one also signs up, the name of the first player might be replaced with the name of the third.
How do i synchronize these things in abap? What mechanism do i have for this? I haven't encountered anything like this in the documentation (i've been studying only for 2 months). Do i have to implement this myself, or is there something to help me?