wrong lines marked on error

Bug #687901 reported by Bugs-valaide
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
valide
New
Medium
Unassigned

Bug Description

Operating system: Win7 64Bit
Vala version: 0.7.8
Valide version (or svn revision): 0.6.1

The attached code throws some errors. The console clearly shows that the
first error is in line 8 (8.28-2.28). But valide marks multiple lines at
some other location on double click of that first error

namespace H32
{
  public class SynchronizedStack<T>
  {
    private LinkedElement<T>? top;
    private Mutex mutex;

    public SynchronizedStack<T>()
    {
      top = null;
      mutex = new Mutex();
    }

    public T pop()
    {
      mutex.lock();

      if (top == null)
      {
        mutex.unlock();
        return null;
      }
      else
      {
        var ret = top.element;
        top = top.next;

        mutex.unlock();

        return ret;
      }
    }

    public void push(T e)
    {
      mutex.lock();

      var le = new LinkedElement<T>();
      le.element = e;

      if (top == null)
        le.next = null;
      else
        le.next = top;

      top = le;

      mutex.unlock();
    }
  }

  private class LinkedElement<T>
  {
    public T element;
    public LinkedElement<T>? next;
  }

  public delegate void Func(Object);

  public class ThreadPool
  {
    private Func func;
    private SynchronizedStack<Object> stack;
    private int maxThreads;
    private int runningThreads;
    private Mutex mutex;

    public ThreadPool(Func f, int maxThreads, bool dings)
    {
      this.func = f;
      this.maxThreads = maxThreads;
      this.runningThreads = 0;
      stack = new SynchronizedStack<Object>();
      mutex = new Mutex();
    }

    public void push(Object data)
    {
      stack.push(data);
      createThreadIfNeeded();
    }

    private void* createThread()
    {
      var res = this.func(this.stack.pop());
      finishThread();
      return res;
    }

    private void createThreadIfNeeded()
    {
      mutex.lock();
      if (runningThreads < maxThreads)
      {
        unowned createrThread = Thread.create(this.createThread, true);
        runningThreads++;
      }
      mutex.unlock();
    }

    private void finishThread()
    {
      mutex.lock();
      runningThreads--;
      mutex.unlock();
    }
  }
}

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.