text
stringlengths
0
14.1k
}
/* ÔËÐÐÈë¿Úº¯Êý */
void CFileQueueThread::run(CThread __attribute__((unused)) *thread, void* args) {
int threadIndex = (int)((long)(args));
int total_count = 0;
int64_t end_time = 0;
int64_t start_time = CTimeUtil::getTime();
bool dosuc = true;
_mutex.lock();
while (!_stop) {
while (_stop == 0 && _queue->isEmpty()) {
_mutex.wait();
}
if (_stop) {
break;
}
queue_item* item = _queue->pop(threadIndex);
int cnt = ++total_count;
if (total_count >= 1000) {
total_count = 0;
end_time = CTimeUtil::getTime();
}
_mutex.unlock();
if (item != NULL) {
if (_handler != NULL) {
_handler->handleQueue(&item->data[0], item->len, threadIndex, _args);
}
dosuc = true;
free(item);
} else {
dosuc = false;
}
if (end_time > start_time) {
TBSYS_LOG(INFO, ""task execute speed: %d task/s"", (int)((int64_t)1000000 * cnt / (end_time - start_time)));
start_time = end_time;
}
_mutex.lock();
if (dosuc) _queue->finish(threadIndex);
}
_mutex.unlock();
}
}
//////////////////END
" gpl-2.0
guaka/trust-metrics trustlet/net_flow/lib/_net_flowmodule.cc 2470 "#include ""Python.h""
#include <glib.h>
#include ""net_flow.hh""
extern ""C"" {
void init_net_flow();
}
void _net_flow_free(void * p)
{
net_flow_free((NetFlow *) p);
}
static PyObject* new_flowobj(PyObject * self, PyObject * args)
{
// no args.
if (!PyArg_ParseTuple(args, """")) {
return NULL;
}
NetFlow * flow = net_flow_new();
return PyCObject_FromVoidPtr(flow, _net_flow_free); // @CTB
}
static PyObject * add_edge(PyObject * self, PyObject * args)
{
PyObject * flow_o;
char * from, * to;
if (!PyArg_ParseTuple(args, ""Oss"", &flow_o, &from, &to)) {
return NULL;
}
NetFlow * flow = (NetFlow *) PyCObject_AsVoidPtr(flow_o);
net_flow_add_edge(flow, from, to);
Py_INCREF(Py_None);
return Py_None;
}
static PyObject * calc_max_flow(PyObject * self, PyObject * args)
{
PyObject * flow_o, * capacities_o;
char * seed_name;
if (!PyArg_ParseTuple(args, ""OsO"", &flow_o, &seed_name, &capacities_o)) {
return NULL;
}
if (!PyList_Check(capacities_o)) { return NULL; }