thrift-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (THRIFT-4292) TimerManager::remove() is not implemented
Date Fri, 08 Sep 2017 14:44:00 GMT

    [ https://issues.apache.org/jira/browse/THRIFT-4292?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16158722#comment-16158722
] 

ASF GitHub Bot commented on THRIFT-4292:
----------------------------------------

Github user Typz commented on a diff in the pull request:

    https://github.com/apache/thrift/pull/1337#discussion_r137808236
  
    --- Diff: lib/cpp/src/thrift/concurrency/TimerManager.cpp ---
    @@ -290,11 +292,23 @@ void TimerManager::add(shared_ptr<Runnable> task, const struct
timeval& value) {
     }
     
     void TimerManager::remove(shared_ptr<Runnable> task) {
    -  (void)task;
       Synchronized s(monitor_);
       if (state_ != TimerManager::STARTED) {
         throw IllegalStateException();
       }
    +  std::vector<task_iterator> toRemove;
    +  for (task_iterator ix = taskMap_.begin(); ix != taskMap_.end(); ++ix) {
    +    if (ix->second->runnable() == task) {
    +      toRemove.push_back(ix);
    +    }
    +  }
    +  if (toRemove.empty()) {
    +    throw NoSuchTaskException();
    +  }
    +  for (std::vector<task_iterator>::iterator ix = toRemove.begin(); ix != toRemove.end();
++ix) {
    +    taskMap_.erase(*ix);
    --- End diff --
    
    Tasks cannot exist multiple times, only newly allocated tasks are inserted:
    ```cpp
      taskMap_.insert(
            std::pair<int64_t, shared_ptr<Task> >(timeout, shared_ptr<Task>(new
Task(task))));
    ```
    
    Which is why I implemented it in the same fashion as the run() method. But i can change
it.


> TimerManager::remove() is not implemented
> -----------------------------------------
>
>                 Key: THRIFT-4292
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4292
>             Project: Thrift
>          Issue Type: Bug
>          Components: C++ - Library
>            Reporter: Francois Ferrand
>
> The function is currently not implemented.
> This is not critical for Thrift, since it is not used there, but prevents using it in
thrift-based code.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message