Esempio n. 1
0
File: ardb.cpp Progetto: Ivasek/ardb
						void Run()
						{
							while (running)
							{
								DBID firstDB = 0, lastDB = 0;
								if (0 == adb->LastDB(lastDB)
								        && 0 == adb->FirstDB(firstDB))
								{
									for (DBID db = firstDB; db <= lastDB; db++)
									{
										DBID nexdb = db;
										if (adb->DBExist(db, nexdb))
										{
											adb->CheckExpireKey(db);
										}
										else
										{
											if (nexdb == db)
											{
												break;
											}
											adb->CheckExpireKey(nexdb);
											db = nexdb;
										}
									}
								}
								uint64 end = get_current_epoch_micros();
								uint64 sleep = check_period;
								if (adb->m_min_expireat > end)
								{
									sleep = (adb->m_min_expireat - end) / 1000;
									if (sleep > check_period)
									{
										sleep = check_period;
									}
									if (sleep == 0)
									{
										sleep = 1;
									}
								}
								Thread::Sleep(sleep);
							}
						}
Esempio n. 2
0
						void Run()
						{
							while (running)
							{
								DBID dbid = 0;
								while (dbid < ARDB_GLOBAL_DB)
								{
									DBID nexdb = 0;
									if (adb->DBExist(dbid, nexdb))
									{
										adb->CheckExpireKey(dbid);
										dbid++;
									} else
									{
										if (nexdb == dbid || nexdb == ARDB_GLOBAL_DB)
										{
											break;
										}
										adb->CheckExpireKey(nexdb);
										dbid = nexdb + 1;
									}
								}
								uint64 end = get_current_epoch_micros();
								uint64 sleep = check_period;
								if (adb->m_min_expireat > end)
								{
									sleep = (adb->m_min_expireat - end) / 1000;
									if (sleep > check_period)
									{
										sleep = check_period;
									}
									if (sleep == 0)
									{
										sleep = 1;
									}
								}
								Thread::Sleep(sleep);
							}
						}