android.os.Process#myTid ( )源码实例Demo

下面列出了android.os.Process#myTid ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Ezalor   文件: IOPools.java
private void open(int fd) {
    LogUtils.logi(IOHook.class.getSimpleName() + " openAfterCall fd:" + fd);

    final IOContext ioContext = getIOContext();
    ioContext.state = IOContext.OPEN;
    ioContext.ioRecord.fd = fd;
    ioContext.ioRecord.path = Utils.getPathByFD(fd);
    ioContext.ioRecord.openTime = System.currentTimeMillis();

    ioContext.ioRecord.process = Utils.getProcessName();
    ioContext.ioRecord.thread = Thread.currentThread().getName();
    ioContext.ioRecord.processId = Process.myPid();
    ioContext.ioRecord.threadId = Process.myTid();

    ioContext.ioRecord.stacktrace = getStackTrace();

    mPools.put(getKey(ioContext.ioRecord.fd), ioContext);
}
 
源代码2 项目: BaseProject   文件: AbsTaskHandlerRunner.java
@Override
public final void run() {
    if (isQuit) {
        return;
    }
    Thread.currentThread().setName(theTaskName);
    mTid = Process.myTid();
    Looper.prepare();
    if (isQuit) {
        return;
    }
    synchronized (this) {
        mLooper = Looper.myLooper();
        notifyAll();
    }
    Process.setThreadPriority(taskPriority);
    taskDispatchHandler = new WeakHandler<>(this, mLooper);
    onLooperPrepared();
    Looper.loop();
    mTid = -1;
}
 
源代码3 项目: Trebuchet   文件: LauncherModel.java
private void unbindItemInfosAndClearQueuedBindRunnables() {
    if (sWorkerThread.getThreadId() == Process.myTid()) {
        throw new RuntimeException("Expected unbindLauncherItemInfos() to be called from the " +
                "main thread");
    }

    // Clear any deferred bind runnables
    synchronized (mDeferredBindRunnables) {
        mDeferredBindRunnables.clear();
    }

    // Remove any queued UI runnables
    mHandler.cancelAll();
    // Unbind all the workspace items
    unbindWorkspaceItemsOnMainThread();
}
 
源代码4 项目: LaunchEnr   文件: LauncherModel.java
/** Runs the specified runnable immediately if called from the main thread, otherwise it is
 * posted on the main thread handler. */
private void runOnMainThread(Runnable r) {
    if (sWorkerThread.getThreadId() == Process.myTid()) {
        // If we are on the worker thread, post onto the main handler
        mHandler.post(r);
    } else {
        r.run();
    }
}
 
源代码5 项目: LaunchEnr   文件: LauncherModel.java
/** Runs the specified runnable immediately if called from the worker thread, otherwise it is
 * posted on the worker thread handler. */
private static void runOnWorkerThread(Runnable r) {
    if (sWorkerThread.getThreadId() == Process.myTid()) {
        r.run();
    } else {
        // If we are not on the worker thread, then post to the worker handler
        sWorker.post(r);
    }
}
 
源代码6 项目: LB-Launcher   文件: LauncherModel.java
private void onlyBindAllApps() {
    final Callbacks oldCallbacks = mCallbacks.get();
    if (oldCallbacks == null) {
        // This launcher has exited and nobody bothered to tell us.  Just bail.
        Log.w(TAG, "LoaderTask running with no launcher (onlyBindAllApps)");
        return;
    }

    // shallow copy
    @SuppressWarnings("unchecked")
    final ArrayList<AppInfo> list
            = (ArrayList<AppInfo>) mBgAllAppsList.data.clone();
    Runnable r = new Runnable() {
        public void run() {
            final long t = SystemClock.uptimeMillis();
            final Callbacks callbacks = tryGetCallbacks(oldCallbacks);
            if (callbacks != null) {
                callbacks.bindAllApplications(list);
            }
            if (DEBUG_LOADERS) {
                Log.d(TAG, "bound all " + list.size() + " apps from cache in "
                        + (SystemClock.uptimeMillis()-t) + "ms");
            }
        }
    };
    boolean isRunningOnMainThread = !(sWorkerThread.getThreadId() == Process.myTid());
    if (isRunningOnMainThread) {
        r.run();
    } else {
        mHandler.post(r);
    }
}
 
源代码7 项目: xmrwallet   文件: MoneroHandlerThread.java
@Override
public void run() {
    mTid = Process.myTid();
    Looper.prepare();
    synchronized (this) {
        mLooper = Looper.myLooper();
        notifyAll();
    }
    Process.setThreadPriority(mPriority);
    onLooperPrepared();
    Looper.loop();
    mTid = -1;
}
 
源代码8 项目: Trebuchet   文件: LauncherModel.java
/** Runs the specified runnable immediately if called from the main thread, otherwise it is
 * posted on the main thread handler. */
@Thunk void runOnMainThread(Runnable r) {
    if (sWorkerThread.getThreadId() == Process.myTid()) {
        // If we are on the worker thread, post onto the main handler
        mHandler.post(r);
    } else {
        r.run();
    }
}
 
源代码9 项目: Trebuchet   文件: LauncherModel.java
/** Runs the specified runnable immediately if called from the worker thread, otherwise it is
 * posted on the worker thread handler. */
@Thunk static void runOnWorkerThread(Runnable r) {
    if (sWorkerThread.getThreadId() == Process.myTid()) {
        r.run();
    } else {
        // If we are not on the worker thread, then post to the worker handler
        sWorker.post(r);
    }
}
 
源代码10 项目: Trebuchet   文件: LauncherModel.java
private void onlyBindAllApps() {
    final Callbacks oldCallbacks = mCallbacks.get();
    if (oldCallbacks == null) {
        // This launcher has exited and nobody bothered to tell us.  Just bail.
        Log.w(TAG, "LoaderTask running with no launcher (onlyBindAllApps)");
        return;
    }

    // shallow copy
    @SuppressWarnings("unchecked")
    final ArrayList<AppInfo> list
            = (ArrayList<AppInfo>) mBgAllAppsList.data.clone();
    final WidgetsModel widgetList = mBgWidgetsModel.clone();
    Runnable r = new Runnable() {
        public void run() {
            final long t = SystemClock.uptimeMillis();
            final Callbacks callbacks = tryGetCallbacks(oldCallbacks);
            if (callbacks != null) {
                callbacks.bindAllApplications(list);
                callbacks.bindAllPackages(widgetList);
            }
            if (DEBUG_LOADERS) {
                Log.d(TAG, "bound all " + list.size() + " apps from cache in "
                        + (SystemClock.uptimeMillis()-t) + "ms");
            }
        }
    };
    boolean isRunningOnMainThread = !(sWorkerThread.getThreadId() == Process.myTid());
    if (isRunningOnMainThread) {
        r.run();
    } else {
        mHandler.post(r);
    }
}
 
源代码11 项目: TurboLauncher   文件: LauncherModel.java
private void runOnMainThread(Runnable r, int type) {
	if (sWorkerThread.getThreadId() == Process.myTid()) {
		// If we are on the worker thread, post onto the main handler
		mHandler.post(r);
	} else {
		r.run();
	}
}
 
源代码12 项目: TurboLauncher   文件: LauncherModel.java
/**
 * Runs the specified runnable immediately if called from the worker thread,
 * otherwise it is posted on the worker thread handler.
 */
private static void runOnWorkerThread(Runnable r) {
	if (sWorkerThread.getThreadId() == Process.myTid()) {
		r.run();
	} else {
		// If we are not on the worker thread, then post to the worker
		// handler
		sWorker.post(r);
	}
}
 
源代码13 项目: TurboLauncher   文件: LauncherModel.java
static Pair<Long, int[]> findNextAvailableIconSpace(Context context,
		String name, Intent launchIntent, int firstScreenIndex,
		ArrayList<Long> workspaceScreens) {
	// Lock on the app so that we don't try and get the items while apps are
	// being added
	LauncherAppState app = LauncherAppState.getInstance();
	LauncherModel model = app.getModel();
	boolean found = false;
	synchronized (app) {
		if (sWorkerThread.getThreadId() != Process.myTid()) {
			// Flush the LauncherModel worker thread, so that if we just did
			// another
			// processInstallShortcut, we give it time for its shortcut to
			// get added to the
			// database (getItemsInLocalCoordinates reads the database)
			model.flushWorkerThread();
		}
		final ArrayList<ItemInfo> items = LauncherModel
				.getItemsInLocalCoordinates(context);

		// Try adding to the workspace screens incrementally, starting at
		// the default or center
		// screen and alternating between +1, -1, +2, -2, etc. (using ~
		// ceil(i/2f)*(-1)^(i-1))
		firstScreenIndex = Math.min(firstScreenIndex,
				workspaceScreens.size());
		int count = workspaceScreens.size();
		for (int screen = firstScreenIndex; screen < count && !found; screen++) {
			int[] tmpCoordinates = new int[2];
			if (findNextAvailableIconSpaceInScreen(items, tmpCoordinates,
					workspaceScreens.get(screen))) {
				// Update the Launcher db
				return new Pair<Long, int[]>(workspaceScreens.get(screen),
						tmpCoordinates);
			}
		}
	}
	return null;
}
 
源代码14 项目: TurboLauncher   文件: LauncherModel.java
public void unbindItemInfosAndClearQueuedBindRunnables() {
	if (sWorkerThread.getThreadId() == Process.myTid()) {
		throw new RuntimeException(
				"Expected unbindLauncherItemInfos() to be called from the "
						+ "main thread");
	}

	// Clear any deferred bind runnables
	mDeferredBindRunnables.clear();
	// Remove any queued bind runnables
	mHandler.cancelAllRunnablesOfType(MAIN_THREAD_BINDING_RUNNABLE);
	// Unbind all the workspace items
	unbindWorkspaceItemsOnMainThread();
}
 
源代码15 项目: LB-Launcher   文件: LauncherModel.java
static Pair<Long, int[]> findNextAvailableIconSpace(Context context, String name,
                                                    Intent launchIntent,
                                                    int firstScreenIndex,
                                                    ArrayList<Long> workspaceScreens) {
    // Lock on the app so that we don't try and get the items while apps are being added
    LauncherAppState app = LauncherAppState.getInstance();
    LauncherModel model = app.getModel();
    boolean found = false;
    synchronized (app) {
        if (sWorkerThread.getThreadId() != Process.myTid()) {
            // Flush the LauncherModel worker thread, so that if we just did another
            // processInstallShortcut, we give it time for its shortcut to get added to the
            // database (getItemsInLocalCoordinates reads the database)
            model.flushWorkerThread();
        }
        final ArrayList<ItemInfo> items = LauncherModel.getItemsInLocalCoordinates(context);

        // Try adding to the workspace screens incrementally, starting at the default or center
        // screen and alternating between +1, -1, +2, -2, etc. (using ~ ceil(i/2f)*(-1)^(i-1))
        firstScreenIndex = Math.min(firstScreenIndex, workspaceScreens.size());
        int count = workspaceScreens.size();
        for (int screen = firstScreenIndex; screen < count && !found; screen++) {
            int[] tmpCoordinates = new int[2];
            if (findNextAvailableIconSpaceInScreen(items, tmpCoordinates,
                    workspaceScreens.get(screen))) {
                // Update the Launcher db
                return new Pair<Long, int[]>(workspaceScreens.get(screen), tmpCoordinates);
            }
        }
    }
    return null;
}
 
源代码16 项目: LB-Launcher   文件: LauncherModel.java
public void unbindItemInfosAndClearQueuedBindRunnables() {
    if (sWorkerThread.getThreadId() == Process.myTid()) {
        throw new RuntimeException("Expected unbindLauncherItemInfos() to be called from the " +
                "main thread");
    }

    // Clear any deferred bind runnables
    synchronized (mDeferredBindRunnables) {
        mDeferredBindRunnables.clear();
    }
    // Remove any queued bind runnables
    mHandler.cancelAllRunnablesOfType(MAIN_THREAD_BINDING_RUNNABLE);
    // Unbind all the workspace items
    unbindWorkspaceItemsOnMainThread();
}
 
源代码17 项目: webrtc_android   文件: PeerConnectionFactory.java
public static ThreadInfo getCurrent() {
  return new ThreadInfo(Thread.currentThread(), Process.myTid());
}
 
源代码18 项目: Trebuchet   文件: Utilities.java
public static void assertWorkerThread() {
    if (LauncherAppState.isDogfoodBuild() &&
            (LauncherModel.sWorkerThread.getThreadId() != Process.myTid())) {
        throw new IllegalStateException();
    }
}
 
源代码19 项目: 365browser   文件: EarlyTraceEvent.java
Event(String name) {
    mName = name;
    mThreadId = Process.myTid();
    mBeginTimeMs = SystemClock.elapsedRealtime();
}
 
源代码20 项目: cronet   文件: EarlyTraceEvent.java
/**
 * Returns a key which consists of |name| and the ID of the current thread.
 * The key is used with pending events making them thread-specific, thus avoiding
 * an exception when similarly named events are started from multiple threads.
 */
@VisibleForTesting
static String makeEventKeyForCurrentThread(String name) {
    return name + "@" + Process.myTid();
}