#include <boost/bind.hpp>
#include <iostream>
#include <string>
#include <windows.h>
using namespace std;
template <class T>
AsynchQueue<T>::AsynchQueue() {
hMutex = CreateMutex(NULL, FALSE, NULL);
hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
}
template <class T>
AsynchQueue<T>::~AsynchQueue() {
CloseHandle(hMutex);
CloseHandle(hEvent);
}
template <class T>
void AsynchQueue<T>::Enqueue(T* data) {
WaitForSingleObject(hMutex, INFINITE);
queue.push_back(data);
ReleaseMutex(hMutex);
SetEvent(hEvent);
}
template <class T>
T *AsynchQueue<T>::Dequeue() {
WaitForSingleObject(hEvent, INFINITE);
WaitForSingleObject(hMutex, INFINITE);
T* data = queue.front();
queue.pop_front();
if (queue.size() > 0) SetEvent(hEvent);
ReleaseMutex(hMutex);
return data;
}
DWORD WINAPI ThreadProcess(LPVOID lpParam);
TaskPool::TaskPool(void)
{
for (int i=0; i<10; i++) {
DWORD dwThreadId;
HANDLE m_thread;
m_thread = CreateThread(
NULL, // default security attributes
0, // default stack size
(LPTHREAD_START_ROUTINE) ThreadProcess,
this, // no thread function arguments
0, // default creation flags
&dwThreadId); // receive thread identifier
threads.push_back(m_thread);
}
}
TaskPool::~TaskPool(void)
{
}
void TaskPool::post(TaskMain *tsk) {
queue.Enqueue(tsk);
}
void TaskPool::start()
{
TaskMain *tsk = queue.Dequeue();
tsk->fun_prt();
}
DWORD WINAPI ThreadProcess(LPVOID lpParam)
{
TaskPool *pool = static_cast<TaskPool *>(lpParam);
while(1)
{
pool->start();
}
return 0;
}
#pragma once
#include "TaskPool.h"
//#include <boost/function.hpp>
//#include <boost/bind.hpp>
#include <iostream>
#include <string>
#include <list>
#include <windows.h>
#include "TaskMain.h"
using namespace std;
/* Asynchronized Queue */
template <class T>
class AsynchQueue {
public:
AsynchQueue();
~AsynchQueue();
void Enqueue(T* data);
T* Dequeue();
private:
list<T*> queue;
HANDLE hMutex;
HANDLE hEvent;
/*AsynchQueue(const AsynchQueue<T>& q);
AsynchQueue &operator=(const AsynchQueue<T>&);*/
};
class TaskPool
{
public:
TaskPool(void);
~TaskPool(void);
void post(TaskMain *tsk);
void start();
//BOOL IsStopping();
private:
/*TaskPool(const TaskPool &);
TaskPool &operator=(const TaskPool &);*/
int m_iThread;
AsynchQueue<TaskMain> queue;
list<HANDLE> threads;
HANDLE hMutex;
BOOL stopMe;
BOOL m_releaseJob;
};
#include "StdAfx.h"
#include "TaskMain.h"
TaskMain::TaskMain(string pstr)
{
}
TaskMain::~TaskMain(void)
{
}
void TaskMain::fun_prt()
{
printf("%s\n",pstr);
}
#pragma once
#include <string>
using namespace std;
class TaskMain
{
public:
string pstr;
void fun_prt();
public:
TaskMain(string pstr);
~TaskMain(void);
};
/*TaskMain *TM = new TaskMain("do again..");
TaskPool tp;
tp.post(TM);*/
分享到:
相关推荐
周福才 《格理论与密码学》一书中LLL算法的python实现。
#0 0x00002b9405ea1c38 in __lll_mutex_lock_wait () from /lib64/libc.so.6 #1 0x00002b9405e45e5f in _L_lock_4026 () from /lib64/libc.so.6 #2 0x00002b9405e42df1 in free () from /lib64/libc.so.6 #3 0x00002...
LLL格基规约的matlab算法程序,能够实现向量的格基规约
Lenstra-Lenstra-Lovasz(LLL)格基约化算法自1982年被提出以来,已被成功应用于计算机代数、编码理论、密码分析、算法数论、整数规划等众多领域。经过三十多年的发展,串行LLL算法的理论分析和实际效率都已得到显著...
比如 m=[19 2 32 46 3 33; 15 42 11 0 3 24; 43 15 0 24 4 16;...>> b=LLL(m) b = 7 -12 -8 4 19 9 -20 4 -9 16 13 16 5 2 33 0 15 -9 -6 -7 -20 -21 8 -12 -10 -24 21 -15 -6 -11 7 4 -9 -11 1 31
python 实现LLL_Algorithm
Computational aspects of geometry of numbers have been revolutionized by the Lenstra–Lenstra–Lov´asz lattice reduction algorithm (LLL), which has led to breakthroughs in fields as diverse as ...
计算理论中最著名的LLL算法及其总结,非常有用的一个理论,现在影响深远
LLL算法的MATLAB程序,用于格点减少的实现
LLL算法的介绍,内容详细清晰,介绍算法的背景,基础,算法实现以及应用,绝对值得学习,欢迎观摩
用matlab实现的LLL算法,实现正交性不好的基转换为正交性较好的基。
LLL算法的分析和应用.pdf
基于 应用密码学手册(包含在压缩包中) 编写的利用LLL算法求解子集和(背包)问题的matlab代码
格缩减LLL算法matlab实现。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。...
介绍LLL1150×600A型刮刀卸料离心脱水机变频调速试验所取得的指标,这些指标与离心强度之间建立了相关性良好的回归方程,并对这些回归方程作了简要分析。
LLL算法原始文献 LLL算法原始文献 LLL算法原始文献
設計模式与思想;;;;;;;;;;;;;;;;;;;;;
"一种改进的GPS整周模糊度降相关LLL算法" 本文概述了一种改进的GPS整周模糊度降相关LLL算法,该算法解决了传统LLL算法中存在的病态Z变换的问题。通过对Gram-Schmidt正交化和行向量内积降序调整矩阵,对模糊度协方差...
采用经典的格基规约LLL算法进行干扰消除,并使用ZF检测。
this program is the LLL algorithm used for lattice reduction