You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by GitBox <gi...@apache.org> on 2019/05/16 08:01:25 UTC

[GitHub] [tinkerpop] jorgebay commented on issue #1114: TINKERPOP-2217

jorgebay commented on issue #1114: TINKERPOP-2217
URL: https://github.com/apache/tinkerpop/pull/1114#issuecomment-492962272
 
 
   Nice catch @danielcweber !
   
   I think we can fix the race condition by peeking after yielding the `_writeInProgress` flag: 
   
   ```c#
           private async Task SendMessagesFromQueueAsync()
           {
               // ...
               Interlocked.CompareExchange(ref _writeInProgress, 0, 1);
   
               // Since the loop ended and the write in progress was set to 0
               // a new item could have been added, write queue can contain items at this time
               if (!_writeQueue.IsEmpty && Interlocked.CompareExchange(ref _writeInProgress, 1, 0) == 1)
               {
                   await SendMessagesFromQueueAsync().ConfigureAwait(false);
               }
           }
   ```
   
   I personally would like this change to the approach proposed in this patch because it requires less effort to review 3 lines of code than 20+ in this sensitive part of the driver. Would you like to change your patch?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services