Skip to content

Commit

Permalink
Update clearTasks
Browse files Browse the repository at this point in the history
  • Loading branch information
yushulx committed Aug 16, 2024
1 parent 8476b71 commit bcea983
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/dynamsoft_barcode_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class WorkerThread
std::mutex m;
std::condition_variable cv;
std::queue<Task> tasks = {};
volatile bool running;
std::atomic<bool> running;
std::thread t;
};

Expand All @@ -60,13 +60,10 @@ typedef struct

void clearTasks(DynamsoftBarcodeReader *self)
{
if (self->worker->tasks.size() > 0)
while (!self->worker->tasks.empty())
{
for (int i = 0; i < self->worker->tasks.size(); i++)
{
free(self->worker->tasks.front().buffer);
self->worker->tasks.pop();
}
free(self->worker->tasks.front().buffer);
self->worker->tasks.pop();
}
}

Expand Down Expand Up @@ -120,7 +117,7 @@ static PyObject *DynamsoftBarcodeReader_new(PyTypeObject *type, PyObject *args,
self = (DynamsoftBarcodeReader *)type->tp_alloc(type, 0);
if (self != NULL)
{
self->hBarcode = DBR_CreateInstance();
self->hBarcode = DBR_CreateInstance();
self->callback = NULL;
self->worker = NULL;
}
Expand Down Expand Up @@ -515,7 +512,6 @@ static PyObject *addAsyncListener(PyObject *obj, PyObject *args)
self->worker->t = std::thread(&run, self);
}


return Py_BuildValue("i", 0);
}

Expand Down

0 comments on commit bcea983

Please sign in to comment.